#include <psmb.h>
#include "psmb_priv.h"
+static void dummy_log(void *log_priv, int priority, const char *format, ...) {}
+
psmb_ctx_t *psmb_new(void)
{
return psmb_new_mm(malloc, free, realloc);
*ctx = (psmb_ctx_t){
.fd = -1,
.malloc = malloc, .free = free, .realloc = realloc,
- .pmtu = PSMB_DEFAULT_PMTU, .port = PSMB_DEFAULT_PORT};
+ .logf = dummy_log,
+ .pmtu = PSMB_DEFAULT_PMTU,
+ .port = PSMB_DEFAULT_PORT};
return ctx;
}
+psmb_result_t psmb_set_logf(psmb_ctx_t *ctx,
+ void (*logf)(void *log_priv, int priority, const char *format, ...),
+ void *log_priv)
+{
+ if (ctx->fd == -1) {
+ ctx->logf = logf;
+ ctx->log_priv = log_priv;
+ return (psmb_result_t){PSMB_OK};
+ } else {
+ errno = EBUSY;
+ return (psmb_result_t){PSMB_ERROR};
+ }
+}
+
psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu)
{
if (ctx->fd == -1) {