diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-06 17:11:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-06 17:11:56 +0100 |
commit | f6240cced088030abb377c5e10bcbd0943e3f2b2 (patch) | |
tree | 91e1c35222590b597bbfef28cac5d98aa60a7f2f /src/libutil/printf.c | |
parent | 8aadb475905cf6f1b2fbfd3cf4834cf8cacff8c8 (diff) | |
download | rspamd-f6240cced088030abb377c5e10bcbd0943e3f2b2.tar.gz rspamd-f6240cced088030abb377c5e10bcbd0943e3f2b2.zip |
Add printing to rspamd_fstring_t.
Diffstat (limited to 'src/libutil/printf.c')
-rw-r--r-- | src/libutil/printf.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c index 9204060b2..345682f28 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -219,6 +219,18 @@ rspamd_printf_append_gstring (const gchar *buf, glong buflen, gpointer ud) return buflen; } +static glong +rspamd_printf_append_fstring (const gchar *buf, glong buflen, gpointer ud) +{ + rspamd_fstring_t **dst = ud; + + if (buflen > 0) { + *dst = rspamd_fstring_append (*dst, buf, buflen); + } + + return buflen; +} + glong rspamd_fprintf (FILE *f, const gchar *fmt, ...) { @@ -307,6 +319,25 @@ rspamd_vprintf_gstring (GString *s, const gchar *fmt, va_list args) return rspamd_vprintf_common (rspamd_printf_append_gstring, s, fmt, args); } +glong +rspamd_printf_fstring (rspamd_fstring_t **s, const gchar *fmt, ...) +{ + va_list args; + glong r; + + va_start (args, fmt); + r = rspamd_vprintf_fstring (s, fmt, args); + va_end (args); + + return r; +} + +glong +rspamd_vprintf_fstring (rspamd_fstring_t **s, const gchar *fmt, va_list args) +{ + return rspamd_vprintf_common (rspamd_printf_append_fstring, s, fmt, args); +} + #define RSPAMD_PRINTF_APPEND(buf, len) \ do { \ RSPAMD_PRINTF_APPEND_BUF(buf, len); \ |