diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-07-13 13:30:16 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-07-13 16:01:00 -0400 |
commit | 2c396fce53100cad4e472f29851f07030a80ee50 (patch) | |
tree | 4bbc7b2d313335600474b7370298a23b460ee356 /src/dstring.h | |
parent | e79f0d038d3ce916e744fd111b70d687f699c0bd (diff) | |
download | bfs-2c396fce53100cad4e472f29851f07030a80ee50.tar.xz |
bfstd: Support wordesc() without allocating
Diffstat (limited to 'src/dstring.h')
-rw-r--r-- | src/dstring.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/dstring.h b/src/dstring.h index 2673f1b..88ca79f 100644 --- a/src/dstring.h +++ b/src/dstring.h @@ -8,6 +8,7 @@ #ifndef BFS_DSTRING_H #define BFS_DSTRING_H +#include "bfstd.h" #include "config.h" #include <stdarg.h> #include <stddef.h> @@ -262,6 +263,36 @@ BFS_FORMATTER(2, 0) int dstrvcatf(char **str, const char *format, va_list args); /** + * Concatenate while shell-escaping. + * + * @param dest + * The destination dynamic string. + * @param str + * The string to escape. + * @param flags + * Flags for wordesc(). + * @return + * 0 on success, -1 on failure. + */ +int dstrescat(char **dest, const char *str, enum wesc_flags flags); + +/** + * Concatenate while shell-escaping. + * + * @param dest + * The destination dynamic string. + * @param str + * The string to escape. + * @param n + * The maximum length of the string. + * @param flags + * Flags for wordesc(). + * @return + * 0 on success, -1 on failure. + */ +int dstrnescat(char **dest, const char *str, size_t n, enum wesc_flags flags); + +/** * Free a dynamic string. * * @param dstr |