Welcome to little lamb

Code » limb » release » tree

[release] / src / liblimb / buffer.h / buffer_patrim_put.c

/* This file is part of limb                           https://lila.oss/limb
 * Copyright (C) 2023 Olivier Brunel                          jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <limb/buffer.h>
#include <limb/patrim.h>
#include <limb/siovec.h>

ssize_t
buffer_patrim_put(buffer *b, u64 id, u64 u, const char *data)
{
    struct iovec v[2];
    char buf[18];

    v[0].iov_base = buf;
    v[0].iov_len = patrim_put(buf, sizeof(buf), 0, id, u);

    v[1].iov_base = (char *) data;
    v[1].iov_len = (patrim_isblob(id)) ? u : 0;

    return buffer_putv(b, v, 2);
}