Commit 3f34fb62 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

Logging: add belle_sip_strcat_vprintf and belle_sip_strcat_printf functions

parent 07d38d86
......@@ -156,6 +156,8 @@ BELLESIP_EXPORT void belle_sip_set_log_handler(belle_sip_log_function_t func);
BELLESIP_EXPORT belle_sip_log_function_t belle_sip_get_log_handler();
BELLESIP_EXPORT char * BELLE_SIP_CHECK_FORMAT_ARGS(1,2) belle_sip_strdup_printf(const char *fmt,...);
BELLESIP_EXPORT char * belle_sip_strcat_vprintf(char* dst, const char *fmt, va_list ap);
BELLESIP_EXPORT char * BELLE_SIP_CHECK_FORMAT_ARGS(2,3) belle_sip_strcat_printf(char* dst, const char *fmt,...);
BELLESIP_EXPORT belle_sip_error_code BELLE_SIP_CHECK_FORMAT_ARGS(4,5) belle_sip_snprintf(char *buff, size_t buff_size, size_t *offset, const char *fmt, ...);
BELLESIP_EXPORT belle_sip_error_code belle_sip_snprintf_valist(char *buff, size_t buff_size, size_t *offset, const char *fmt, va_list args);
......
......@@ -121,6 +121,34 @@ char *belle_sip_strdup_printf(const char *fmt,...){
return ret;
}
char * belle_sip_strcat_vprintf(char* dst, const char *fmt, va_list ap){
char *ret;
unsigned long dstlen, retlen;
ret=belle_sip_strdup_vprintf(fmt, ap);
dstlen = strlen(dst);
retlen = strlen(ret);
if ((dst = belle_sip_realloc(dst, dstlen+retlen+1)) != NULL){
strncat(dst,ret,retlen);
dst[dstlen+retlen] = '\0';
belle_sip_free(ret);
return dst;
} else {
belle_sip_free(ret);
return NULL;
}
}
char *belle_sip_strcat_printf(char* dst, const char *fmt,...){
char *ret;
va_list args;
va_start (args, fmt);
ret=belle_sip_strcat_vprintf(dst, fmt, args);
va_end (args);
return ret;
}
belle_sip_error_code belle_sip_snprintf(char *buff, size_t buff_size, size_t *offset, const char *fmt, ...) {
belle_sip_error_code ret;
va_list args;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment