diff --git a/mongoose.c b/mongoose.c index b2f6d9f78509b75b70da54b41d80c4a6182ca33d..bad492b49b22f4d63d4946d74282ec352a37918e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4307,6 +4307,8 @@ struct mg_cgi_env_block { int nvars; /* Number of variables in envp[] */ }; +#ifndef MG_DISABLE_FILESYSTEM + #define MIME_ENTRY(_ext, _type) \ { _ext, sizeof(_ext) - 1, _type } static const struct { @@ -4364,8 +4366,6 @@ static const struct { MIME_ENTRY("bmp", "image/bmp"), {NULL, 0, NULL}}; -#ifndef MG_DISABLE_FILESYSTEM - #ifndef MG_DISABLE_DAV static int mg_mkdir(const char *path, uint32_t mode) { #ifndef _WIN32 @@ -10203,6 +10203,33 @@ int mg_set_protocol_coap(struct mg_connection *nc) { #define CONSOLE_UART UARTA0_BASE +#ifdef __TI_COMPILER_VERSION__ +int asprintf(char **strp, const char *fmt, ...) { + va_list ap; + int len; + + *strp = malloc(BUFSIZ); + if (*strp == NULL) return -1; + + va_start(ap, fmt); + len = vsnprintf(*strp, BUFSIZ, fmt, ap); + va_end(ap); + + if (len > 0) { + *strp = realloc(*strp, len); + if (*strp == NULL) return -1; + } + + if (len >= BUFSIZ) { + va_start(ap, fmt); + len = vsnprintf(*strp, len, fmt, ap); + va_end(ap); + } + + return len; +} +#endif /* __TI_COMPILER_VERSION__ */ + #ifndef __TI_COMPILER_VERSION__ int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) { #else diff --git a/mongoose.h b/mongoose.h index 75a763a217498f50fddd2a9a15028820bd54cd9f..e8834faccebd2f6927ddd1ff4f6bb6b0f81e7692 100644 --- a/mongoose.h +++ b/mongoose.h @@ -449,6 +449,9 @@ extern "C" { struct SlTimeval_t; #define timeval SlTimeval_t int gettimeofday(struct timeval *t, void *tz); + +int asprintf(char **strp, const char *fmt, ...); + #endif long int random(void);