Files
djhackersdev_bemanitools/src/main/util/iobuf.c
T
icex2 f9c0733af3 Adapt everything in BT5 to new capnhook API
This includes:
- Renaming of functions (iohook_invoke_next)
- Slight interface changes (com_proxy_wrap, iohook_push_handler)
- De-duplicate stuff from utils (iobuf, hr)
2020-09-02 19:35:15 +00:00

43 lines
885 B
C

#define LOG_MODULE "util-iobuf"
#include "util/hex.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/mem.h"
void iobuf_log(struct iobuf *buffer, const char *tag)
{
char *str;
size_t str_len;
str_len = buffer->nbytes * 2 + 1;
str = xmalloc(str_len);
log_misc(
"[%s] (%d %d)", tag, (uint32_t) buffer->nbytes, (uint32_t) buffer->pos);
hex_encode_uc(buffer->bytes, buffer->nbytes, str, str_len);
log_misc("[%s]: %s", tag, str);
free(str);
}
void iobuf_log_const(struct const_iobuf *buffer, const char *tag)
{
char *str;
size_t str_len;
str_len = buffer->nbytes * 2 + 1;
str = xmalloc(str_len);
log_misc(
"[%s] (%d %d)", tag, (uint32_t) buffer->nbytes, (uint32_t) buffer->pos);
hex_encode_uc(buffer->bytes, buffer->nbytes, str, str_len);
log_misc("[%s]: %s", tag, str);
free(str);
}