示例#1
0
static int contacts_to_str(const void *obj, const intptr_t *args, char **buf)
{
	const struct ast_sip_aor *aor = obj;
	RAII_VAR(struct ast_str *, str, ast_str_create(MAX_OBJECT_FIELD), ast_free);

	ast_sip_for_each_contact(aor, ast_sip_contact_to_str, &str);
	ast_str_truncate(str, -1);

	*buf = ast_strdup(ast_str_buffer(str));
	if (!*buf) {
		return -1;
	}

	return 0;
}
示例#2
0
static void send_eivr_event(struct ast_iostream *stream, const char event, const char *data,
	const struct ast_channel *chan)
{
	struct ast_str *tmp = ast_str_create(12);

	ast_str_append(&tmp, 0, "%c,%10d", event, (int)time(NULL));
	if (data) {
		ast_str_append(&tmp, 0, ",%s", data);
	}
	ast_str_append(&tmp, 0, "\n");
	ast_iostream_write(stream, ast_str_buffer(tmp), strlen(ast_str_buffer(tmp)));
	ast_str_truncate(tmp, -1);

	ast_debug(1, "sent '%s'", ast_str_buffer(tmp));
	ast_free(tmp);
}
示例#3
0
static int contacts_to_str(const void *obj, const intptr_t *args, char **buf)
{
	const struct ast_sip_aor *aor = obj;
	struct ast_str *str;

	str = ast_str_create(MAX_OBJECT_FIELD);
	if (!str) {
		*buf = NULL;
		return -1;
	}

	ast_sip_for_each_contact(aor, ast_sip_contact_to_str, &str);
	ast_str_truncate(str, -1);

	*buf = ast_strdup(ast_str_buffer(str));
	ast_free(str);

	return *buf ? 0 : -1;
}