Browse Source

Add %e modifier for GError clever printing.

tags/0.9.0
Vsevolod Stakhov 9 years ago
parent
commit
f07041e176
2 changed files with 20 additions and 0 deletions
  1. 19
    0
      src/libutil/printf.c
  2. 1
    0
      src/libutil/printf.h

+ 19
- 0
src/libutil/printf.c View File

@@ -339,6 +339,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
guint width, sign, hex, humanize, bytes, frac_width, i;
rspamd_fstring_t *v;
GString *gs;
GError *err;
gboolean bv;

while (*fmt) {
@@ -462,6 +463,24 @@ rspamd_vprintf_common (rspamd_printf_append_func func,

continue;

case 'e':
err = va_arg (args, GError *);

if (err) {
p = err->message;

if (p == NULL) {
p = "(NULL)";
}
}
else {
p = "unknown error";
}

slen = strlen (p);
RSPAMD_PRINTF_APPEND (p, slen);
break;

case 's':
p = va_arg (args, gchar *);
if (p == NULL) {

+ 1
- 0
src/libutil/printf.h View File

@@ -52,6 +52,7 @@
* %Z '\0'
* %N '\n'
* %c gchar
* %e GError *
* %% %
*
*/

Loading…
Cancel
Save