static int list_expect(struct test_list *test_list, char *expect, struct ast_str **buf) { struct test_val *i; ast_str_reset(*buf); AST_LIST_TRAVERSE(test_list, i, list) { ast_str_append(buf, 0, "%s", i->name); }
static char *file2display(struct ast_str **buf, ssize_t len, const char *input) { const char *ptr; ast_str_reset(*buf); for (ptr = input; *ptr; ptr++) { if (*ptr == '\n') { ast_str_append(buf, len, "\\n"); } else if (*ptr == '\r') { ast_str_append(buf, len, "\\r"); } else if (*ptr == '\t') { ast_str_append(buf, len, "\\t"); } else if (*ptr < ' ' || *ptr > 125) { ast_str_append(buf, len, "\\x%hhX", *ptr); } else { ast_str_append(buf, len, "%c", *ptr); } } return ast_str_buffer(*buf); }