aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/printf_hook.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-07-13 11:38:29 +0200
committerMartin Willi <martin@revosec.ch>2012-07-13 13:23:29 +0200
commit1b40b74de032b36c199c4c65016e4736c09b6c81 (patch)
tree69890bf5598be303bdbe721d21eca840434a513e /src/libstrongswan/printf_hook.c
parent549eba30abf99e88a7a197ce80aebf9d91e78e83 (diff)
downloadstrongswan-1b40b74de032b36c199c4c65016e4736c09b6c81.tar.bz2
strongswan-1b40b74de032b36c199c4c65016e4736c09b6c81.tar.xz
Pass opaque data to printf hooks and print_in_hook()
Diffstat (limited to 'src/libstrongswan/printf_hook.c')
-rw-r--r--src/libstrongswan/printf_hook.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstrongswan/printf_hook.c b/src/libstrongswan/printf_hook.c
index c3b5191fd..1ffe550c7 100644
--- a/src/libstrongswan/printf_hook.c
+++ b/src/libstrongswan/printf_hook.c
@@ -90,12 +90,16 @@ static int custom_print(FILE *stream, const struct printf_info *info,
char buf[PRINTF_BUF_LEN];
printf_hook_spec_t spec;
printf_hook_handler_t *handler = printf_hooks[SPEC_TO_INDEX(info->spec)];
+ printf_hook_data_t data = {
+ .buf = buf,
+ .buflen = sizeof(buf),
+ };
spec.hash = info->alt;
spec.minus = info->left;
spec.width = info->width;
- written = handler->hook(buf, sizeof(buf), &spec, args);
+ written = handler->hook(&data, &spec, args);
if (written > 0)
{
ignore_result(fwrite(buf, 1, written, stream));
@@ -150,6 +154,10 @@ static int custom_fmt_cb(Vstr_base *base, size_t pos, Vstr_fmt_spec *fmt_spec)
const void *args[ARGS_MAX];
printf_hook_spec_t spec;
printf_hook_handler_t *handler = printf_hooks[SPEC_TO_INDEX(fmt_spec->name[0])];
+ printf_hook_data_t data = {
+ .buf = buf,
+ .buflen = sizeof(buf),
+ };
for (i = 0; i < handler->numargs; i++)
{
@@ -168,7 +176,7 @@ static int custom_fmt_cb(Vstr_base *base, size_t pos, Vstr_fmt_spec *fmt_spec)
spec.minus = fmt_spec->fmt_minus;
spec.width = fmt_spec->fmt_field_width;
- written = handler->hook(buf, sizeof(buf), &spec, args);
+ written = handler->hook(&data, &spec, args);
if (written > 0)
{
vstr_add_buf(base, pos, buf, written);