]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/iovec-util.h
f1e4be88d43d1be8f68c461707a809180401a89d
[thirdparty/systemd.git] / src / basic / iovec-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/uio.h> /* IWYU pragma: export */
5
6 #include "forward.h"
7 #include "iovec-util-fundamental.h" /* IWYU pragma: export */
8
9 extern const struct iovec iovec_nul_byte; /* Points to a single NUL byte */
10 extern const struct iovec iovec_empty; /* Points to an empty, but valid (i.e. non-NULL) pointer */
11
12 size_t iovec_total_size(const struct iovec *iovec, size_t n) _nonnull_if_nonzero_(1, 2);
13
14 bool iovec_increment(struct iovec *iovec, size_t n, size_t k) _nonnull_if_nonzero_(1, 2);
15
16 struct iovec* iovec_make_string(struct iovec *iovec, const char *s);
17
18 #define IOVEC_MAKE_STRING(s) \
19 *iovec_make_string(&(struct iovec) {}, s)
20
21 #define CONST_IOVEC_MAKE_STRING(s) \
22 (const struct iovec) { \
23 .iov_base = (char*) s, \
24 .iov_len = STRLEN(s), \
25 }
26
27 void iovec_done_erase(struct iovec *iovec);
28
29 char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
30 char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);
31
32 void iovec_array_free(struct iovec *iovec, size_t n_iovec) _nonnull_if_nonzero_(1, 2);
33
34 int iovec_memcmp(const struct iovec *a, const struct iovec *b) _pure_;
35
36 struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret);
37
38 struct iovec* iovec_append(struct iovec *iovec, const struct iovec *append);