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