Pass opaque data to printf hooks and print_in_hook()

This commit is contained in:
Martin Willi
2012-07-13 13:23:29 +02:00
parent 549eba30ab
commit 1b40b74de0
16 changed files with 98 additions and 74 deletions
+3 -3
View File
@@ -100,7 +100,7 @@ METHOD(host_t, is_anyaddr, bool,
/**
* Described in header.
*/
int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
int host_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
const void *const *args)
{
private_host_t *this = *((private_host_t**)(args[0]));
@@ -152,9 +152,9 @@ int host_printf_hook(char *dst, size_t dstlen, printf_hook_spec_t *spec,
}
if (spec->minus)
{
return print_in_hook(dst, dstlen, "%-*s", spec->width, buffer);
return print_in_hook(data, "%-*s", spec->width, buffer);
}
return print_in_hook(dst, dstlen, "%*s", spec->width, buffer);
return print_in_hook(data, "%*s", spec->width, buffer);
}
METHOD(host_t, get_address, chunk_t,
+1 -1
View File
@@ -213,7 +213,7 @@ host_t *host_create_any(int family);
* host_t *host
* Use #-modifier to include port number
*/
int host_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
int host_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
const void *const *args);
#endif /** HOST_H_ @}*/
+5 -5
View File
@@ -756,8 +756,8 @@ METHOD(identification_t, matches_dn, id_match_t,
/**
* Described in header.
*/
int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
const void *const *args)
int identification_printf_hook(printf_hook_data_t *data,
printf_hook_spec_t *spec, const void *const *args)
{
private_identification_t *this = *((private_identification_t**)(args[0]));
chunk_t proper;
@@ -765,7 +765,7 @@ int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
if (this == NULL)
{
return print_in_hook(dst, len, "%*s", spec->width, "(null)");
return print_in_hook(data, "%*s", spec->width, "(null)");
}
switch (this->type)
@@ -821,9 +821,9 @@ int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
}
if (spec->minus)
{
return print_in_hook(dst, len, "%-*s", spec->width, buf);
return print_in_hook(data, "%-*s", spec->width, buf);
}
return print_in_hook(dst, len, "%*s", spec->width, buf);
return print_in_hook(data, "%*s", spec->width, buf);
}
METHOD(identification_t, clone_, identification_t*,
+2 -2
View File
@@ -342,7 +342,7 @@ identification_t * identification_create_from_sockaddr(sockaddr_t *sockaddr);
* Arguments are:
* identification_t *identification
*/
int identification_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
const void *const *args);
int identification_printf_hook(printf_hook_data_t *data,
printf_hook_spec_t *spec, const void *const *args);
#endif /** IDENTIFICATION_H_ @}*/