summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-09-10 19:49:16 +0200
committerGravatar Martin Szulecki2012-03-19 01:39:07 +0100
commit4e518231cf5ff4485fdaf4d52c4f51aa48e5255d (patch)
tree7d9b248399b6bae1fbe209d1dc1d9662b1a0f361 /src
parentd619762b8eb9e0ef180018e8731744a5c9a8a6bd (diff)
downloadlibimobiledevice-4e518231cf5ff4485fdaf4d52c4f51aa48e5255d.tar.gz
libimobiledevice-4e518231cf5ff4485fdaf4d52c4f51aa48e5255d.tar.bz2
Add asprintf replacement for systems lacking it
Diffstat (limited to 'src')
-rw-r--r--src/asprintf.h23
-rw-r--r--src/debug.c4
-rw-r--r--src/lockdown.c1
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 @@
1#ifndef ASPRINTF_H
2#define ASPRINTF_H
3#ifndef vasprintf
4static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP)
5{
6 int res;
7 *PTR = (char*)malloc(512);
8 res = vsnprintf(*PTR, 512, TEMPLATE, AP);
9 return res;
10}
11#endif
12#ifndef asprintf
13static inline int asprintf(char **PTR, const char *TEMPLATE, ...)
14{
15 int res;
16 va_list AP;
17 va_start(AP, TEMPLATE);
18 res = vasprintf(PTR, TEMPLATE, AP);
19 va_end(AP);
20 return res;
21}
22#endif
23#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 @@
34#include "debug.h" 34#include "debug.h"
35#include "libimobiledevice/libimobiledevice.h" 35#include "libimobiledevice/libimobiledevice.h"
36 36
37#ifndef STRIP_DEBUG_CODE
38#include "asprintf.h"
39#endif
40
37int debug_level = 0; 41int debug_level = 0;
38 42
39/** 43/**
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 @@
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#include "asprintf.h"
38 39
39#define RESULT_SUCCESS 0 40#define RESULT_SUCCESS 0
40#define RESULT_FAILURE 1 41#define RESULT_FAILURE 1