From 098aca8fe945d5c220ce5bfaa5020972e0f685c1 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 28 Nov 2020 11:30:38 -0500 Subject: dstring: New dstrdcat(), dstrcatf(), dstrvcatf() functions --- dstring.h | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'dstring.h') diff --git a/dstring.h b/dstring.h index b556313..54106f3 100644 --- a/dstring.h +++ b/dstring.h @@ -1,6 +1,6 @@ /**************************************************************************** * bfs * - * Copyright (C) 2016-2019 Tavian Barnes * + * Copyright (C) 2016-2020 Tavian Barnes * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted. * @@ -106,6 +106,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. * @@ -142,6 +154,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. * -- cgit v1.2.3