76#define str _private_str_
78#define n_alloc _private_n_alloc_
186 bool was_null = (astr->
n == 0);
194 n1 = (3 * (astr->
n_alloc + 10)) / 2;
219 const char *format, va_list ap)
234 req_len =
fc_vsnprintf(buffer, buffer_size, format, ap);
235 if (req_len + 1 > buffer_size) {
238 req_len =
fc_vsnprintf(buffer, buffer_size, format, copy);
239 if (req_len > buffer_size) {
241 req_len = buffer_size;
248 req_len =
fc_vsnprintf(buffer, buffer_size, format, ap);
250 if (req_len > buffer_size) {
252 req_len = buffer_size;
271 va_start(args, format);
291 va_start(args, format);
304 va_start(args, format);
330 const char *
const *items,
size_t number)
338 astr_set(astr,
Q_(
"?or-list-single:%s"), *items);
339 }
else if (2 == number) {
341 astr_set(astr,
Q_(
"?or-list:%s or %s"), items[0], items[1]);
348 while (1 < --number) {
351 astr_add(astr,
Q_(
"?or-list:, %s"), *items++);
355 astr_add(astr,
Q_(
"?or-list:, or %s"), *items);
368 const char *
const *items,
size_t number)
376 astr_set(astr,
Q_(
"?and-list-single:%s"), *items);
377 }
else if (2 == number) {
379 astr_set(astr,
Q_(
"?and-list:%s and %s"), items[0], items[1]);
386 while (1 < --number) {
389 astr_add(astr,
Q_(
"?and-list:, %s"), *items++);
393 astr_add(astr,
Q_(
"?and-list:, and %s"), *items);
static char * astr_buffer_get(size_t *alloc)
void astr_free(struct astring *astr)
const char * astr_build_or_list(struct astring *astr, const char *const *items, size_t number)
static void astr_buffer_free(void)
void astr_vadd(struct astring *astr, const char *format, va_list ap)
void astr_set(struct astring *astr, const char *format,...)
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
void astr_add_line(struct astring *astr, const char *format,...)
void astr_reserve(struct astring *astr, size_t n)
void astr_clear(struct astring *astr)
static void astr_vadd_at(struct astring *astr, size_t at, const char *format, va_list ap)
void astr_init(struct astring *astr)
char * astr_to_str(struct astring *astr)
void astr_add(struct astring *astr, const char *format,...)
static char * astr_buffer_grow(size_t request, size_t *alloc)
static const struct astring zero_astr
static char * astr_buffer
static fc_mutex astr_mutex
static size_t astr_buffer_alloc
void astr_break_lines(struct astring *astr, size_t desired_len)
void astr_copy(struct astring *dest, const struct astring *src)
static size_t astr_len(const struct astring *astr) fc__attribute((nonnull(1)))
static bool astr_empty(const struct astring *astr) fc__attribute((nonnull(1)))
void fc_allocate_mutex(fc_mutex *mutex)
void fc_release_mutex(fc_mutex *mutex)
void fc_destroy_mutex(fc_mutex *mutex)
void fc_init_mutex(fc_mutex *mutex)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
#define fc_realloc(ptr, sz)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
int fc_break_lines(char *str, size_t desired_len)