1 /* CC0 (Public domain) - see LICENSE file for details */
2 #include <ccan/stringbuilder/stringbuilder.h>
6 int stringbuilder_args(char* str, size_t str_sz, const char* delim, ...)
11 res = stringbuilder_va(str, str_sz, delim, ap);
16 static int stringbuilder_cpy(
17 char** str, size_t* str_sz, const char* s, size_t s_len)
34 int stringbuilder_va(char* str, size_t str_sz, const char* delim, va_list ap)
38 const char* s = va_arg(ap, const char*);
41 delim_len = strlen(delim);
43 res = stringbuilder_cpy(&str, &str_sz, s, 0);
44 s = va_arg(ap, const char*);
46 res = stringbuilder_cpy(&str, &str_sz,
49 res = stringbuilder_cpy(&str, &str_sz,
51 s = va_arg(ap, const char*);
57 int stringbuilder_array(char* str, size_t str_sz, const char* delim,
58 size_t n_strings, const char** strings)
64 delim_len = strlen(delim);
66 res = stringbuilder_cpy(&str, &str_sz,
68 while(--n_strings && !res) {
69 res = stringbuilder_cpy(&str, &str_sz,
72 res = stringbuilder_cpy(&str, &str_sz,