1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <stddef.h>
6
7 #include "macro.h"
8
9 size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool *ret_truncated);
strnpcpy(char ** dest,size_t size,const char * src,size_t len)10 static inline size_t strnpcpy(char **dest, size_t size, const char *src, size_t len) {
11 return strnpcpy_full(dest, size, src, len, NULL);
12 }
13 size_t strpcpy_full(char **dest, size_t size, const char *src, bool *ret_truncated);
strpcpy(char ** dest,size_t size,const char * src)14 static inline size_t strpcpy(char **dest, size_t size, const char *src) {
15 return strpcpy_full(dest, size, src, NULL);
16 }
17 size_t strpcpyf_full(char **dest, size_t size, bool *ret_truncated, const char *src, ...) _printf_(4, 5);
18 #define strpcpyf(dest, size, src, ...) \
19 strpcpyf_full((dest), (size), NULL, (src), ##__VA_ARGS__)
20 size_t strpcpyl_full(char **dest, size_t size, bool *ret_truncated, const char *src, ...) _sentinel_;
21 #define strpcpyl(dest, size, src, ...) \
22 strpcpyl_full((dest), (size), NULL, (src), ##__VA_ARGS__)
23 size_t strnscpy_full(char *dest, size_t size, const char *src, size_t len, bool *ret_truncated);
strnscpy(char * dest,size_t size,const char * src,size_t len)24 static inline size_t strnscpy(char *dest, size_t size, const char *src, size_t len) {
25 return strnscpy_full(dest, size, src, len, NULL);
26 }
27 size_t strscpy_full(char *dest, size_t size, const char *src, bool *ret_truncated);
strscpy(char * dest,size_t size,const char * src)28 static inline size_t strscpy(char *dest, size_t size, const char *src) {
29 return strscpy_full(dest, size, src, NULL);
30 }
31 size_t strscpyl_full(char *dest, size_t size, bool *ret_truncated, const char *src, ...) _sentinel_;
32 #define strscpyl(dest, size, src, ...) \
33 strscpyl_full(dest, size, NULL, src, ##__VA_ARGS__)
34