diff options
author | Nikias Bassen | 2011-09-10 19:49:16 +0200 |
---|---|---|
committer | Martin Szulecki | 2012-03-19 01:39:07 +0100 |
commit | 4e518231cf5ff4485fdaf4d52c4f51aa48e5255d (patch) | |
tree | 7d9b248399b6bae1fbe209d1dc1d9662b1a0f361 | |
parent | d619762b8eb9e0ef180018e8731744a5c9a8a6bd (diff) | |
download | libimobiledevice-4e518231cf5ff4485fdaf4d52c4f51aa48e5255d.tar.gz libimobiledevice-4e518231cf5ff4485fdaf4d52c4f51aa48e5255d.tar.bz2 |
Add asprintf replacement for systems lacking it
-rw-r--r-- | src/asprintf.h | 23 | ||||
-rw-r--r-- | src/debug.c | 4 | ||||
-rw-r--r-- | src/lockdown.c | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/asprintf.h b/src/asprintf.h new file mode 100644 index 0000000..6f1250d --- /dev/null +++ b/src/asprintf.h @@ -0,0 +1,23 @@ +#ifndef ASPRINTF_H +#define ASPRINTF_H +#ifndef vasprintf +static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) +{ + int res; + *PTR = (char*)malloc(512); + res = vsnprintf(*PTR, 512, TEMPLATE, AP); + return res; +} +#endif +#ifndef asprintf +static inline int asprintf(char **PTR, const char *TEMPLATE, ...) +{ + int res; + va_list AP; + va_start(AP, TEMPLATE); + res = vasprintf(PTR, TEMPLATE, AP); + va_end(AP); + return res; +} +#endif +#endif diff --git a/src/debug.c b/src/debug.c index ece2b1d..b1c528d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -34,6 +34,10 @@ #include "debug.h" #include "libimobiledevice/libimobiledevice.h" +#ifndef STRIP_DEBUG_CODE +#include "asprintf.h" +#endif + int debug_level = 0; /** diff --git a/src/lockdown.c b/src/lockdown.c index 424cf89..0f1e1b2 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -35,6 +35,7 @@ #include "idevice.h" #include "debug.h" #include "userpref.h" +#include "asprintf.h" #define RESULT_SUCCESS 0 #define RESULT_FAILURE 1 |