Pass opaque data to printf hooks and print_in_hook()
This commit is contained in:
@@ -616,7 +616,7 @@ static status_t add_string_algo(private_proposal_t *this, chunk_t alg)
|
||||
/**
|
||||
* print all algorithms of a kind to buffer
|
||||
*/
|
||||
static int print_alg(private_proposal_t *this, char **dst, size_t *len,
|
||||
static int print_alg(private_proposal_t *this, printf_hook_data_t *data,
|
||||
u_int kind, void *names, bool *first)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
@@ -628,16 +628,16 @@ static int print_alg(private_proposal_t *this, char **dst, size_t *len,
|
||||
{
|
||||
if (*first)
|
||||
{
|
||||
written += print_in_hook(*dst, *len, "%N", names, alg);
|
||||
written += print_in_hook(data, "%N", names, alg);
|
||||
*first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(*dst, *len, "/%N", names, alg);
|
||||
written += print_in_hook(data, "/%N", names, alg);
|
||||
}
|
||||
if (size)
|
||||
{
|
||||
written += print_in_hook(*dst, *len, "_%u", size);
|
||||
written += print_in_hook(data, "_%u", size);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
@@ -647,7 +647,7 @@ static int print_alg(private_proposal_t *this, char **dst, size_t *len,
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int proposal_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
{
|
||||
private_proposal_t *this = *((private_proposal_t**)(args[0]));
|
||||
@@ -658,7 +658,7 @@ int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
|
||||
if (this == NULL)
|
||||
{
|
||||
return print_in_hook(dst, len, "(null)");
|
||||
return print_in_hook(data, "(null)");
|
||||
}
|
||||
|
||||
if (spec->hash)
|
||||
@@ -668,28 +668,28 @@ int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
{ /* call recursivly */
|
||||
if (first)
|
||||
{
|
||||
written += print_in_hook(dst, len, "%P", this);
|
||||
written += print_in_hook(data, "%P", this);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, ", %P", this);
|
||||
written += print_in_hook(data, ", %P", this);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return written;
|
||||
}
|
||||
|
||||
written = print_in_hook(dst, len, "%N:", protocol_id_names, this->protocol);
|
||||
written += print_alg(this, &dst, &len, ENCRYPTION_ALGORITHM,
|
||||
written = print_in_hook(data, "%N:", protocol_id_names, this->protocol);
|
||||
written += print_alg(this, data, ENCRYPTION_ALGORITHM,
|
||||
encryption_algorithm_names, &first);
|
||||
written += print_alg(this, &dst, &len, INTEGRITY_ALGORITHM,
|
||||
written += print_alg(this, data, INTEGRITY_ALGORITHM,
|
||||
integrity_algorithm_names, &first);
|
||||
written += print_alg(this, &dst, &len, PSEUDO_RANDOM_FUNCTION,
|
||||
written += print_alg(this, data, PSEUDO_RANDOM_FUNCTION,
|
||||
pseudo_random_function_names, &first);
|
||||
written += print_alg(this, &dst, &len, DIFFIE_HELLMAN_GROUP,
|
||||
written += print_alg(this, data, DIFFIE_HELLMAN_GROUP,
|
||||
diffie_hellman_group_names, &first);
|
||||
written += print_alg(this, &dst, &len, EXTENDED_SEQUENCE_NUMBERS,
|
||||
written += print_alg(this, data, EXTENDED_SEQUENCE_NUMBERS,
|
||||
extended_sequence_numbers_names, &first);
|
||||
return written;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ proposal_t *proposal_create_from_string(protocol_id_t protocol, const char *algs
|
||||
* With the #-specifier, arguments are:
|
||||
* linked_list_t *list containing proposal_t*
|
||||
*/
|
||||
int proposal_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int proposal_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
#endif /** PROPOSAL_H_ @}*/
|
||||
|
||||
@@ -658,7 +658,7 @@ u_int32_t chunk_hash(chunk_t chunk)
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int chunk_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
{
|
||||
chunk_t *chunk = *((chunk_t**)(args[0]));
|
||||
@@ -670,7 +670,7 @@ int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
{
|
||||
u_int chunk_len = chunk->len;
|
||||
const void *new_args[] = {&chunk->ptr, &chunk_len};
|
||||
return mem_printf_hook(dst, len, spec, new_args);
|
||||
return mem_printf_hook(data, spec, new_args);
|
||||
}
|
||||
|
||||
while (copy.len > 0)
|
||||
@@ -681,9 +681,9 @@ int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, ":");
|
||||
written += print_in_hook(data, ":");
|
||||
}
|
||||
written += print_in_hook(dst, len, "%02x", *copy.ptr++);
|
||||
written += print_in_hook(data, "%02x", *copy.ptr++);
|
||||
copy.len--;
|
||||
}
|
||||
return written;
|
||||
|
||||
@@ -312,7 +312,7 @@ u_int32_t chunk_hash_inc(chunk_t chunk, u_int32_t hash);
|
||||
* chunk_t *chunk
|
||||
* Use #-modifier to print a compact version
|
||||
*/
|
||||
int chunk_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int chunk_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
#endif /** CHUNK_H_ @}*/
|
||||
|
||||
@@ -60,7 +60,7 @@ int enum_from_name(enum_name_t *e, char *name)
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int enum_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int enum_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
{
|
||||
enum_name_t *ed = *((enum_name_t**)(args[0]));
|
||||
@@ -70,10 +70,10 @@ int enum_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
return print_in_hook(dst, len, "(%d)", val);
|
||||
return print_in_hook(data, "(%d)", val);
|
||||
}
|
||||
else
|
||||
{
|
||||
return print_in_hook(dst, len, "%s", name);
|
||||
return print_in_hook(data, "%s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ int enum_from_name(enum_name_t *e, char *name);
|
||||
* Arguments are:
|
||||
* enum_names_t *names, int value
|
||||
*/
|
||||
int enum_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int enum_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
#endif /** ENUM_H_ @}*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
typedef struct printf_hook_t printf_hook_t;
|
||||
typedef struct printf_hook_spec_t printf_hook_spec_t;
|
||||
typedef struct printf_hook_data_t printf_hook_data_t;
|
||||
typedef enum printf_hook_argtype_t printf_hook_argtype_t;
|
||||
|
||||
#if !defined(USE_VSTR) && \
|
||||
@@ -90,13 +91,12 @@ int vstr_wrapper_vasprintf(char **str, const char *format, va_list ap);
|
||||
/**
|
||||
* Callback function type for printf hooks.
|
||||
*
|
||||
* @param dst destination buffer
|
||||
* @param len length of the buffer
|
||||
* @param data hook data, to pass to print_in_hook()
|
||||
* @param spec format specifier
|
||||
* @param args arguments array
|
||||
* @return number of characters written
|
||||
*/
|
||||
typedef int (*printf_hook_function_t)(char *dst, size_t len,
|
||||
typedef int (*printf_hook_function_t)(printf_hook_data_t *data,
|
||||
printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
@@ -104,17 +104,33 @@ typedef int (*printf_hook_function_t)(char *dst, size_t len,
|
||||
* Helper macro to be used in printf hook callbacks.
|
||||
* buf and buflen get modified.
|
||||
*/
|
||||
#define print_in_hook(buf, buflen, fmt, ...) ({\
|
||||
int _written = snprintf(buf, buflen, fmt, ##__VA_ARGS__);\
|
||||
if (_written < 0 || _written >= buflen)\
|
||||
#define print_in_hook(data, fmt, ...) ({\
|
||||
int _written = snprintf(data->buf, data->buflen, fmt, ##__VA_ARGS__);\
|
||||
if (_written < 0 || _written >= data->buflen)\
|
||||
{\
|
||||
_written = buflen - 1;\
|
||||
_written = data->buflen - 1;\
|
||||
}\
|
||||
buf += _written;\
|
||||
buflen -= _written;\
|
||||
data->buf += _written;\
|
||||
data->buflen -= _written;\
|
||||
_written;\
|
||||
})
|
||||
|
||||
/**
|
||||
* Data to pass to a printf hook.
|
||||
*/
|
||||
struct printf_hook_data_t {
|
||||
|
||||
/**
|
||||
* Buffer to write to
|
||||
*/
|
||||
char *buf;
|
||||
|
||||
/**
|
||||
* Size of the buffer
|
||||
*/
|
||||
size_t buflen;
|
||||
};
|
||||
|
||||
/**
|
||||
* Properties of the format specifier
|
||||
*/
|
||||
|
||||
@@ -179,8 +179,8 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol, ts
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
int traffic_selector_printf_hook(printf_hook_data_t *data,
|
||||
printf_hook_spec_t *spec, const void *const *args)
|
||||
{
|
||||
private_traffic_selector_t *this = *((private_traffic_selector_t**)(args[0]));
|
||||
linked_list_t *list = *((linked_list_t**)(args[0]));
|
||||
@@ -195,7 +195,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
|
||||
if (this == NULL)
|
||||
{
|
||||
return print_in_hook(dst, len, "(null)");
|
||||
return print_in_hook(data, "(null)");
|
||||
}
|
||||
|
||||
if (spec->hash)
|
||||
@@ -204,7 +204,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
while (enumerator->enumerate(enumerator, (void**)&this))
|
||||
{
|
||||
/* call recursivly */
|
||||
written += print_in_hook(dst, len, "%R ", this);
|
||||
written += print_in_hook(data, "%R ", this);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return written;
|
||||
@@ -216,7 +216,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
memeq(this->from, from, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16) &&
|
||||
memeq(this->to, to, this->type == TS_IPV4_ADDR_RANGE ? 4 : 16))
|
||||
{
|
||||
written += print_in_hook(dst, len, "dynamic");
|
||||
written += print_in_hook(data, "dynamic");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -238,11 +238,11 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
{
|
||||
inet_ntop(AF_INET6, &this->to6, to_str, sizeof(to_str));
|
||||
}
|
||||
written += print_in_hook(dst, len, "%s..%s", from_str, to_str);
|
||||
written += print_in_hook(data, "%s..%s", from_str, to_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, "%s/%d", from_str, this->netbits);
|
||||
written += print_in_hook(data, "%s/%d", from_str, this->netbits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
return written;
|
||||
}
|
||||
|
||||
written += print_in_hook(dst, len, "[");
|
||||
written += print_in_hook(data, "[");
|
||||
|
||||
/* build protocol string */
|
||||
if (has_proto)
|
||||
@@ -264,18 +264,18 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
|
||||
if (proto)
|
||||
{
|
||||
written += print_in_hook(dst, len, "%s", proto->p_name);
|
||||
written += print_in_hook(data, "%s", proto->p_name);
|
||||
serv_proto = proto->p_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, "%d", this->protocol);
|
||||
written += print_in_hook(data, "%d", this->protocol);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_proto && has_ports)
|
||||
{
|
||||
written += print_in_hook(dst, len, "/");
|
||||
written += print_in_hook(data, "/");
|
||||
}
|
||||
|
||||
/* build port string */
|
||||
@@ -287,20 +287,20 @@ int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec
|
||||
|
||||
if (serv)
|
||||
{
|
||||
written += print_in_hook(dst, len, "%s", serv->s_name);
|
||||
written += print_in_hook(data, "%s", serv->s_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, "%d", this->from_port);
|
||||
written += print_in_hook(data, "%d", this->from_port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
written += print_in_hook(dst, len, "%d-%d", this->from_port, this->to_port);
|
||||
written += print_in_hook(data, "%d-%d", this->from_port, this->to_port);
|
||||
}
|
||||
}
|
||||
|
||||
written += print_in_hook(dst, len, "]");
|
||||
written += print_in_hook(data, "]");
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ traffic_selector_t *traffic_selector_create_dynamic(u_int8_t protocol,
|
||||
* With the #-specifier, arguments are:
|
||||
* linked_list_t *list containing traffic_selector_t*
|
||||
*/
|
||||
int traffic_selector_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
int traffic_selector_printf_hook(printf_hook_data_t *data,
|
||||
printf_hook_spec_t *spec, const void *const *args);
|
||||
|
||||
#endif /** TRAFFIC_SELECTOR_H_ @}*/
|
||||
|
||||
@@ -450,7 +450,7 @@ _cas_impl(ptr, void*)
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int time_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
{
|
||||
static const char* months[] = {
|
||||
@@ -463,7 +463,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
|
||||
if (time == UNDEFINED_TIME)
|
||||
{
|
||||
return print_in_hook(dst, len, "--- -- --:--:--%s----",
|
||||
return print_in_hook(data, "--- -- --:--:--%s----",
|
||||
utc ? " UTC " : " ");
|
||||
}
|
||||
if (utc)
|
||||
@@ -474,7 +474,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
{
|
||||
localtime_r(time, &t);
|
||||
}
|
||||
return print_in_hook(dst, len, "%s %02d %02d:%02d:%02d%s%04d",
|
||||
return print_in_hook(data, "%s %02d %02d:%02d:%02d%s%04d",
|
||||
months[t.tm_mon], t.tm_mday, t.tm_hour, t.tm_min,
|
||||
t.tm_sec, utc ? " UTC " : " ", t.tm_year + 1900);
|
||||
}
|
||||
@@ -482,7 +482,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int time_delta_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args)
|
||||
{
|
||||
char* unit = "second";
|
||||
@@ -505,7 +505,7 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
delta /= 60;
|
||||
unit = "minute";
|
||||
}
|
||||
return print_in_hook(dst, len, "%" PRIu64 " %s%s", delta, unit,
|
||||
return print_in_hook(data, "%" PRIu64 " %s%s", delta, unit,
|
||||
(delta == 1) ? "" : "s");
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ static char hexdig_upper[] = "0123456789ABCDEF";
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
int mem_printf_hook(char *dst, size_t dstlen,
|
||||
int mem_printf_hook(printf_hook_data_t *data,
|
||||
printf_hook_spec_t *spec, const void *const *args)
|
||||
{
|
||||
char *bytes = *((void**)(args[0]));
|
||||
@@ -534,7 +534,7 @@ int mem_printf_hook(char *dst, size_t dstlen,
|
||||
int i = 0;
|
||||
int written = 0;
|
||||
|
||||
written += print_in_hook(dst, dstlen, "=> %u bytes @ %p", len, bytes);
|
||||
written += print_in_hook(data, "=> %u bytes @ %p", len, bytes);
|
||||
|
||||
while (bytes_pos < bytes_roof)
|
||||
{
|
||||
@@ -555,7 +555,7 @@ int mem_printf_hook(char *dst, size_t dstlen,
|
||||
*buffer_pos++ = '\0';
|
||||
ascii_buffer[i] = '\0';
|
||||
|
||||
written += print_in_hook(dst, dstlen, "\n%4d: %s %s",
|
||||
written += print_in_hook(data, "\n%4d: %s %s",
|
||||
line_start, buffer, ascii_buffer);
|
||||
|
||||
buffer_pos = buffer;
|
||||
|
||||
@@ -653,7 +653,7 @@ bool cas_ptr(void **ptr, void *oldval, void *newval);
|
||||
* Arguments are:
|
||||
* time_t* time, bool utc
|
||||
*/
|
||||
int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int time_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
/**
|
||||
@@ -662,7 +662,7 @@ int time_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
* Arguments are:
|
||||
* time_t* begin, time_t* end
|
||||
*/
|
||||
int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int time_delta_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
/**
|
||||
@@ -671,7 +671,7 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
* Arguments are:
|
||||
* u_char *ptr, u_int len
|
||||
*/
|
||||
int mem_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
||||
int mem_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
const void *const *args);
|
||||
|
||||
#endif /** UTILS_H_ @}*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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_ @}*/
|
||||
|
||||
@@ -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*,
|
||||
|
||||
@@ -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_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user