add esl to windows build

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10909 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2008-12-22 16:50:45 +00:00
parent 33afc2a6d9
commit 6f2677a53d
3 changed files with 270 additions and 2 deletions

View File

@@ -311,6 +311,43 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st
return ESL_SUCCESS;
}
static int esl_vasprintf(char **ret, const char *fmt, va_list ap)
{
#ifndef WIN32
return vasprintf(ret, fmt, ap);
#else
char *buf;
int len;
size_t buflen;
va_list ap2;
char *tmp = NULL;
#ifdef _MSC_VER
#if _MSC_VER >= 1500
/* hack for incorrect assumption in msvc header files for code analysis */
__analysis_assume(tmp);
#endif
ap2 = ap;
#else
va_copy(ap2, ap);
#endif
len = vsnprintf(tmp, 0, fmt, ap2);
if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
len = vsnprintf(buf, buflen, fmt, ap);
*ret = buf;
} else {
*ret = NULL;
len = -1;
}
va_end(ap2);
return len;
#endif
}
esl_status_t esl_event_add_header(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *fmt, ...)
{
int ret = 0;
@@ -318,7 +355,7 @@ esl_status_t esl_event_add_header(esl_event_t *event, esl_stack_t stack, const c
va_list ap;
va_start(ap, fmt);
ret = vasprintf(&data, fmt, ap);
ret = esl_vasprintf(&data, fmt, ap);
va_end(ap);
if (ret == -1) {
@@ -344,7 +381,7 @@ esl_status_t esl_event_add_body(esl_event_t *event, const char *fmt, ...)
va_list ap;
if (fmt) {
va_start(ap, fmt);
ret = vasprintf(&data, fmt, ap);
ret = esl_vasprintf(&data, fmt, ap);
va_end(ap);
if (ret == -1) {