summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asprintf.h33
-rw-r--r--tools/ideviceimagemounter.c1
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 @@
+#ifndef ASPRINTF_H
+#define ASPRINTF_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef HAVE_VASPRINTF
+static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP)
+{
+ int res;
+ res = vsnprintf(NULL, 32768, TEMPLATE, AP);
+ if (res > 0) {
+ *PTR = (char*)malloc(res+1);
+ res = vsnprintf(*PTR, res, TEMPLATE, AP);
+ }
+ return res;
+}
+#endif
+
+#ifndef HAVE_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 /* 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 @@
#include <libimobiledevice/afc.h>
#include <libimobiledevice/notification_proxy.h>
#include <libimobiledevice/mobile_image_mounter.h>
+#include <asprintf.h>
static int indent_level = 0;