diff options
| -rw-r--r-- | include/asprintf.h | 33 | ||||
| -rw-r--r-- | tools/ideviceimagemounter.c | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/include/asprintf.h b/include/asprintf.h new file mode 100644 index 0000000..3b0072e --- /dev/null +++ b/include/asprintf.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #ifndef ASPRINTF_H | ||
| 2 | #define ASPRINTF_H | ||
| 3 | |||
| 4 | #ifdef HAVE_CONFIG_H | ||
| 5 | #include <config.h> | ||
| 6 | #endif | ||
| 7 | |||
| 8 | #ifndef HAVE_VASPRINTF | ||
| 9 | static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) | ||
| 10 | { | ||
| 11 | int res; | ||
| 12 | res = vsnprintf(NULL, 32768, TEMPLATE, AP); | ||
| 13 | if (res > 0) { | ||
| 14 | *PTR = (char*)malloc(res+1); | ||
| 15 | res = vsnprintf(*PTR, res, TEMPLATE, AP); | ||
| 16 | } | ||
| 17 | return res; | ||
| 18 | } | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #ifndef HAVE_ASPRINTF | ||
| 22 | static inline int asprintf(char **PTR, const char *TEMPLATE, ...) | ||
| 23 | { | ||
| 24 | int res; | ||
| 25 | va_list AP; | ||
| 26 | va_start(AP, TEMPLATE); | ||
| 27 | res = vasprintf(PTR, TEMPLATE, AP); | ||
| 28 | va_end(AP); | ||
| 29 | return res; | ||
| 30 | } | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #endif /* ASPRINTF_H */ | ||
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index b4512f5..ce690de 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include <libimobiledevice/afc.h> | 37 | #include <libimobiledevice/afc.h> |
| 38 | #include <libimobiledevice/notification_proxy.h> | 38 | #include <libimobiledevice/notification_proxy.h> |
| 39 | #include <libimobiledevice/mobile_image_mounter.h> | 39 | #include <libimobiledevice/mobile_image_mounter.h> |
| 40 | #include <asprintf.h> | ||
| 40 | 41 | ||
| 41 | static int indent_level = 0; | 42 | static int indent_level = 0; |
| 42 | 43 | ||
