diff options
| author | 2011-09-14 01:39:02 +0200 | |
|---|---|---|
| committer | 2012-03-19 01:43:00 +0100 | |
| commit | 0df63036c888220ea2d5c122f3c19861b0959167 (patch) | |
| tree | 05febc2ead4e0b426eda479823b2ae1e254c96f4 | |
| parent | a87e507134f674f06b3150b1e588a3707c6f4277 (diff) | |
| download | libimobiledevice-0df63036c888220ea2d5c122f3c19861b0959167.tar.gz libimobiledevice-0df63036c888220ea2d5c122f3c19861b0959167.tar.bz2 | |
Refined asprintf/vasprintf detection and inclusion
| -rw-r--r-- | configure.ac | 9 | ||||
| -rw-r--r-- | src/asprintf.h | 20 | ||||
| -rw-r--r-- | src/debug.c | 2 | ||||
| -rw-r--r-- | src/lockdown.c | 2 |
4 files changed, 24 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index 98b0008..1bb33fa 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -54,6 +54,15 @@ AC_FUNC_MALLOC | |||
| 54 | AC_FUNC_REALLOC | 54 | AC_FUNC_REALLOC |
| 55 | AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) | 55 | AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) |
| 56 | 56 | ||
| 57 | AC_CHECK_FUNC(asprintf, [have_asprintf="yes"], [have_asprintf="no"]) | ||
| 58 | if test "x$have_asprintf" = "xyes"; then | ||
| 59 | AC_DEFINE(HAVE_ASPRINTF,1,[define if asprintf is available]) | ||
| 60 | fi | ||
| 61 | AC_CHECK_FUNC(vasprintf, [have_vasprintf="yes"], [have_vasprintf="no"]) | ||
| 62 | if test "x$have_vasprintf" = "xyes"; then | ||
| 63 | AC_DEFINE(HAVE_VASPRINTF,1,[define if vasprintf is available]) | ||
| 64 | fi | ||
| 65 | |||
| 57 | AC_DEFINE(LITTLE_ENDIAN,0,[little endian]) | 66 | AC_DEFINE(LITTLE_ENDIAN,0,[little endian]) |
| 58 | AC_DEFINE(BIG_ENDIAN,1,[big endian]) | 67 | AC_DEFINE(BIG_ENDIAN,1,[big endian]) |
| 59 | AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], []) | 68 | AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], []) |
diff --git a/src/asprintf.h b/src/asprintf.h index 6f1250d..3b0072e 100644 --- a/src/asprintf.h +++ b/src/asprintf.h | |||
| @@ -1,15 +1,24 @@ | |||
| 1 | #ifndef ASPRINTF_H | 1 | #ifndef ASPRINTF_H |
| 2 | #define ASPRINTF_H | 2 | #define ASPRINTF_H |
| 3 | #ifndef vasprintf | 3 | |
| 4 | #ifdef HAVE_CONFIG_H | ||
| 5 | #include <config.h> | ||
| 6 | #endif | ||
| 7 | |||
| 8 | #ifndef HAVE_VASPRINTF | ||
| 4 | static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) | 9 | static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) |
| 5 | { | 10 | { |
| 6 | int res; | 11 | int res; |
| 7 | *PTR = (char*)malloc(512); | 12 | res = vsnprintf(NULL, 32768, TEMPLATE, AP); |
| 8 | res = vsnprintf(*PTR, 512, TEMPLATE, AP); | 13 | if (res > 0) { |
| 14 | *PTR = (char*)malloc(res+1); | ||
| 15 | res = vsnprintf(*PTR, res, TEMPLATE, AP); | ||
| 16 | } | ||
| 9 | return res; | 17 | return res; |
| 10 | } | 18 | } |
| 11 | #endif | 19 | #endif |
| 12 | #ifndef asprintf | 20 | |
| 21 | #ifndef HAVE_ASPRINTF | ||
| 13 | static inline int asprintf(char **PTR, const char *TEMPLATE, ...) | 22 | static inline int asprintf(char **PTR, const char *TEMPLATE, ...) |
| 14 | { | 23 | { |
| 15 | int res; | 24 | int res; |
| @@ -20,4 +29,5 @@ static inline int asprintf(char **PTR, const char *TEMPLATE, ...) | |||
| 20 | return res; | 29 | return res; |
| 21 | } | 30 | } |
| 22 | #endif | 31 | #endif |
| 23 | #endif | 32 | |
| 33 | #endif /* ASPRINTF_H */ | ||
diff --git a/src/debug.c b/src/debug.c index 49ec7c7..b1c528d 100644 --- a/src/debug.c +++ b/src/debug.c | |||
| @@ -35,10 +35,8 @@ | |||
| 35 | #include "libimobiledevice/libimobiledevice.h" | 35 | #include "libimobiledevice/libimobiledevice.h" |
| 36 | 36 | ||
| 37 | #ifndef STRIP_DEBUG_CODE | 37 | #ifndef STRIP_DEBUG_CODE |
| 38 | #ifndef HAVE_ASPRINTF | ||
| 39 | #include "asprintf.h" | 38 | #include "asprintf.h" |
| 40 | #endif | 39 | #endif |
| 41 | #endif | ||
| 42 | 40 | ||
| 43 | int debug_level = 0; | 41 | int debug_level = 0; |
| 44 | 42 | ||
diff --git a/src/lockdown.c b/src/lockdown.c index e3d557c..0f1e1b2 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -35,9 +35,7 @@ | |||
| 35 | #include "idevice.h" | 35 | #include "idevice.h" |
| 36 | #include "debug.h" | 36 | #include "debug.h" |
| 37 | #include "userpref.h" | 37 | #include "userpref.h" |
| 38 | #ifndef HAVE_ASPRINTF | ||
| 39 | #include "asprintf.h" | 38 | #include "asprintf.h" |
| 40 | #endif | ||
| 41 | 39 | ||
| 42 | #define RESULT_SUCCESS 0 | 40 | #define RESULT_SUCCESS 0 |
| 43 | #define RESULT_FAILURE 1 | 41 | #define RESULT_FAILURE 1 |
