diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 07:48:52 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 07:48:52 +0000 |
commit | 57f651a43ce4438c514272ea6ef751aba4a61015 (patch) | |
tree | 866eb94bc74c00134445d6327f15fb390e708e99 | |
parent | 2161a93e6e03ac398ad5d5f7b87c1cc13706ab3c (diff) |
Bug 6829 - asprintf for Solaris
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@18755 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | include/asterisk/compat.h | 2 | ||||
-rw-r--r-- | utils.c | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h index afb290169..4ed0b7a5d 100644 --- a/include/asterisk/compat.h +++ b/include/asterisk/compat.h @@ -71,6 +71,7 @@ int unsetenv(const char *name); #endif #endif /* __CYGWIN__ */ +#define HAVE_ASPRINTF #define HAVE_VASPRINTF #define HAVE_STRTOQ @@ -89,6 +90,7 @@ int unsetenv(const char *name); #endif #ifdef SOLARIS +#undef HAVE_ASPRINTF #undef HAVE_VASPRINTF #undef HAVE_STRTOQ #endif @@ -766,6 +766,40 @@ int vasprintf(char **strp, const char *fmt, va_list ap) } #endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ +/* + * Based on Code from bsd-asprintf from OpenSSH + * Copyright (c) 2004 Darren Tucker. + * + * Based originally on asprintf.c from OpenBSD: + * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) +int asprintf(char **str, const char *fmt, ...) +{ + va_list ap; + int ret; + + *str = NULL; + va_start(ap, fmt); + ret = vasprintf(str, fmt, ap); + va_end(ap); + + return ret; +} +#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ + #ifndef HAVE_STRTOQ #ifndef LONG_MIN #define LONG_MIN (-9223372036854775807L-1L) |