diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-11-28 11:30:38 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-11-28 11:33:18 -0500 |
commit | 098aca8fe945d5c220ce5bfaa5020972e0f685c1 (patch) | |
tree | f8d62ccaf78f43e100f6c07fae0ca3a2cb5a8f54 /dstring.h | |
parent | c7c8a03a3783cfeb342f033a7cac0dcbe948bbb9 (diff) |
dstring: New dstrdcat(), dstrcatf(), dstrvcatf() functions
Diffstat (limited to 'dstring.h')
-rw-r--r-- | dstring.h | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -1,6 +1,6 @@ /**************************************************************************** * bfs * - * Copyright (C) 2016-2019 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2016-2020 Tavian Barnes <tavianator@tavianator.com> * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted. * @@ -107,6 +107,18 @@ int dstrcat(char **dest, const char *src); int dstrncat(char **dest, const char *src, size_t n); /** + * Append a dynamic string to another dynamic string. + * + * @param dest + * The destination dynamic string. + * @param src + * The dynamic string to append. + * @return + * 0 on success, -1 on failure. + */ +int dstrdcat(char **dest, const char *src); + +/** * Append a single character to a dynamic string. * * @param str @@ -143,6 +155,35 @@ char *dstrprintf(const char *format, ...); char *dstrvprintf(const char *format, va_list args); /** + * Format some text onto the end of a dynamic string. + * + * @param str + * The destination dynamic string. + * @param format + * The format string to fill in. + * @param ... + * Any arguments for the format string. + * @return + * 0 on success, -1 on failure. + */ +BFS_FORMATTER(2, 3) +int dstrcatf(char **str, const char *format, ...); + +/** + * Format some text from a va_list onto the end of a dynamic string. + * + * @param str + * The destination dynamic string. + * @param format + * The format string to fill in. + * @param args + * The arguments for the format string. + * @return + * 0 on success, -1 on failure. + */ +int dstrvcatf(char **str, const char *format, va_list args); + +/** * Free a dynamic string. * * @param dstr |