From 17c5372cd9dd9efb93296e03377910e2ff40b61f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 24 Nov 2014 11:06:33 +0100 Subject: [PATCH] Add API to set/get a LinphoneContent data with a string type. --- coreapi/content.c | 9 +++++++++ coreapi/content.h | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/coreapi/content.c b/coreapi/content.c index 84e45c853..74d04ebb7 100644 --- a/coreapi/content.c +++ b/coreapi/content.c @@ -115,6 +115,15 @@ void linphone_content_set_buffer(LinphoneContent *content, const void *buffer, s ((char *)content->lcp.data)[size] = '\0'; } +char * linphone_content_get_string_buffer(const LinphoneContent *content) { + return (char *)content->lcp.data; +} + +void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer) { + content->lcp.size = strlen(buffer); + content->lcp.data = belle_sip_strdup(buffer); +} + size_t linphone_content_get_size(const LinphoneContent *content) { return content->lcp.size; } diff --git a/coreapi/content.h b/coreapi/content.h index b2e04de27..400f5f5fb 100644 --- a/coreapi/content.h +++ b/coreapi/content.h @@ -155,10 +155,25 @@ LINPHONE_PUBLIC void * linphone_content_get_buffer(const LinphoneContent *conten /** * Set the content data buffer, usually a string. * @param[in] content LinphoneContent object. - * @param[in] data The content data buffer. + * @param[in] buffer The content data buffer. + * @param[in] size The size of the content data buffer. */ LINPHONE_PUBLIC void linphone_content_set_buffer(LinphoneContent *content, const void *buffer, size_t size); +/** + * Get the string content data buffer. + * @param[in] content LinphoneContent object + * @return The string content data buffer. + */ +LINPHONE_PUBLIC char * linphone_content_get_string_buffer(const LinphoneContent *content); + +/** + * Set the string content data buffer. + * @param[in] content LinphoneContent object. + * @param[in] buffer The string content data buffer. + */ +LINPHONE_PUBLIC void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer); + /** * Get the content data buffer size, excluding null character despite null character is always set for convenience. * @param[in] content LinphoneContent object.