X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Fstr%2Fstr.h;h=0fe542cf235eeb9c08119f0de14ced6f6050a0ea;hp=4bb06b70c141ba47941a436fffe10cd53c7c6c82;hb=97d99004bec31012400b6c1d9bad045ae1c9b075;hpb=a5ebf3146a57b7db05f6b6e2de0f2689a1b06751 diff --git a/ccan/tal/str/str.h b/ccan/tal/str/str.h index 4bb06b70..0fe542cf 100644 --- a/ccan/tal/str/str.h +++ b/ccan/tal/str/str.h @@ -1,8 +1,11 @@ /* Licensed under BSD-MIT - see LICENSE file for details */ #ifndef CCAN_STR_TAL_H #define CCAN_STR_TAL_H +#ifdef TAL_USE_TALLOC +#include +#else #include -#include +#endif #include #include @@ -24,21 +27,40 @@ char *tal_strdup(const tal_t *ctx, const char *p); char *tal_strndup(const tal_t *ctx, const char *p, size_t n); /** - * tal_asprintf - allocate a formatted string + * tal_fmt - allocate a formatted string * @ctx: NULL, or tal allocated object to be parent. * @fmt: the printf-style format (can be take()). */ -char *tal_asprintf(const tal_t *ctx, const char *fmt, ...) PRINTF_FMT(2,3); +char *tal_fmt(const tal_t *ctx, const char *fmt, ...) PRINTF_FMT(2,3); /** - * tal_vasprintf - allocate a formatted string (va_list version) + * tal_vfmt - allocate a formatted string (va_list version) * @ctx: NULL, or tal allocated object to be parent. * @fmt: the printf-style format (can be take()). * @va: the va_list containing the format args. */ -char *tal_vasprintf(const tal_t *ctx, const char *fmt, va_list ap) +char *tal_vfmt(const tal_t *ctx, const char *fmt, va_list ap) PRINTF_FMT(2,0); +/** + * tal_append_fmt - append a formatted string to a talloc string. + * @baseptr: a pointer to the tal string to be appended to. + * @fmt: the printf-style format (can be take()). + * + * Returns false on allocation failure. + */ +bool tal_append_fmt(char **baseptr, const char *fmt, ...) PRINTF_FMT(2,3); + +/** + * tal_append_vfmt - append a formatted string to a talloc string (va_list) + * @baseptr: a pointer to the tal string to be appended to. + * @fmt: the printf-style format (can be take()). + * @va: the va_list containing the format args. + * + * Returns false on allocation failure. + */ +bool tal_append_vfmt(char **baseptr, const char *fmt, va_list ap); + /** * tal_strcat - join two strings together * @ctx: NULL, or tal allocated object to be parent.