/* 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 <errno.h>
#include <string.h>
#include <limb/buffer.h>
#include <limb/patrim.h>
#include <limb/siovec.h>
ssize_t
buffer_patrim_putv(buffer *b, u64 id, const struct iovec v[], unsigned int n)
{
if (!patrim_isblob(id)) return (errno = EINVAL, -1);
char buf[18];
struct iovec vv[1 + n];
vv[0].iov_base = buf;
vv[0].iov_len = patrim_put(buf, sizeof(buf), 0, id, siov_len(v, n));
memcpy(vv + 1, v, sizeof(*v) * n);
return buffer_putv(b, vv, 1 + n);
}