From 6ef7d05283f9005e379e63a6f58c22302b8136a7 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 16 Nov 2005 13:09:32 +0000 Subject: [PATCH] Added cfg_printf(), which will be useful for formatting of error messages used in configuration parsers. --- lib/conf.c | 10 ++++++++++ lib/conf.h | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/conf.c b/lib/conf.c index 2293cdae..7f593d8e 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -58,6 +58,16 @@ cfg_strdup(byte *s) return mp_strdup(cfpool, s); } +byte * +cfg_printf(char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + byte *res = mp_vprintf(cfpool, fmt, args); + va_end(args); + return res; +} + void cf_register(struct cfitem *items) { if(items[0].type!=CT_SECTION && items[0].type!=CT_INCOMPLETE_SECTION) diff --git a/lib/conf.h b/lib/conf.h index 85a9ebe5..ef727512 100644 --- a/lib/conf.h +++ b/lib/conf.h @@ -21,6 +21,7 @@ extern struct mempool *cfpool; void *cfg_malloc(uns size); void *cfg_malloc_zero(uns size); byte *cfg_strdup(byte *s); +byte *cfg_printf(char *fmt, ...) FORMAT_CHECK(printf,1,2); /* * Every module places its configuration setting into some section. Section is -- 2.39.2