summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am18
-rw-r--r--tools/ideviceimagemounter.c25
-rw-r--r--tools/ideviceinfo.c66
-rw-r--r--tools/idevicepair.c3
-rw-r--r--tools/idevicesyslog.c3
5 files changed, 92 insertions, 23 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index bb13eb9..f23b0b1 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,9 +1,13 @@
AM_CPPFLAGS = -I$(top_srcdir)/include
-AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS)
-AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
+AM_CFLAGS = $(GLOBAL_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(LFS_CFLAGS)
+AM_LDFLAGS = $(libgnutls_LIBS) $(libtasn1_LIBS)
-bin_PROGRAMS = idevice_id ideviceinfo idevicepair idevicesyslog idevicebackup idevicebackup2 ideviceimagemounter idevicescreenshot ideviceenterrecovery idevicedate
+bin_PROGRAMS = idevice_id ideviceinfo idevicepair idevicesyslog ideviceimagemounter idevicescreenshot ideviceenterrecovery idevicedate
+
+if HAVE_GLIB2
+bin_PROGRAMS += idevicebackup idevicebackup2
+endif
ideviceinfo_SOURCES = ideviceinfo.c
ideviceinfo_CFLAGS = $(AM_CFLAGS)
@@ -26,13 +30,13 @@ idevice_id_LDFLAGS = $(AM_LDFLAGS)
idevice_id_LDADD = ../src/libimobiledevice.la
idevicebackup_SOURCES = idevicebackup.c
-idevicebackup_CFLAGS = $(AM_CFLAGS)
-idevicebackup_LDFLAGS = $(AM_LDFLAGS)
+idevicebackup_CFLAGS = $(AM_CFLAGS) $(libglib2_CFLAGS)
+idevicebackup_LDFLAGS = $(AM_LDFLAGS) $(libglib2_LIBS)
idevicebackup_LDADD = ../src/libimobiledevice.la
idevicebackup2_SOURCES = idevicebackup2.c
-idevicebackup2_CFLAGS = $(AM_CFLAGS)
-idevicebackup2_LDFLAGS = $(AM_LDFLAGS)
+idevicebackup2_CFLAGS = $(AM_CFLAGS) $(libglib2_CFLAGS)
+idevicebackup2_LDFLAGS = $(AM_LDFLAGS) $(libglib2_LIBS)
idevicebackup2_LDADD = ../src/libimobiledevice.la
ideviceimagemounter_SOURCES = ideviceimagemounter.c
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index 3fb4ac5..b4512f5 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -28,8 +28,9 @@
#include <string.h>
#include <getopt.h>
#include <errno.h>
-#include <glib.h>
#include <libgen.h>
+#include <time.h>
+#include <sys/time.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -165,7 +166,7 @@ static void plist_node_to_string(plist_t node)
double d;
uint8_t b;
uint64_t u = 0;
- GTimeVal tv = { 0, 0 };
+ struct timeval tv = { 0, 0 };
plist_type t;
@@ -214,9 +215,23 @@ static void plist_node_to_string(plist_t node)
case PLIST_DATE:
plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec);
- s = g_time_val_to_iso8601(&tv);
- printf("%s\n", s);
- free(s);
+ {
+ time_t ti = (time_t)tv.tv_sec;
+ struct tm *btime = localtime(&ti);
+ if (btime) {
+ s = (char*)malloc(24);
+ memset(s, 0, 24);
+ if (strftime(s, 24, "%Y-%m-%dT%H:%M:%SZ", btime) <= 0) {
+ free (s);
+ s = NULL;
+ }
+ }
+ }
+ if (s) {
+ puts(s);
+ free(s);
+ }
+ puts("\n");
break;
case PLIST_ARRAY:
diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c
index c5c060e..6633459 100644
--- a/tools/ideviceinfo.c
+++ b/tools/ideviceinfo.c
@@ -23,7 +23,8 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
-#include <glib.h>
+#include <time.h>
+#include <sys/time.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -58,6 +59,36 @@ static const char *domains[] = {
NULL
};
+static const char base64_str[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char base64_pad = '=';
+
+static char *base64encode(const unsigned char *buf, size_t size)
+{
+ if (!buf || !(size > 0)) return NULL;
+ int outlen = (size / 3) * 4;
+ char *outbuf = (char*)malloc(outlen+5); // 4 spare bytes + 1 for '\0'
+ size_t n = 0;
+ size_t m = 0;
+ unsigned char input[3];
+ unsigned int output[4];
+ while (n < size) {
+ input[0] = buf[n];
+ input[1] = (n+1 < size) ? buf[n+1] : 0;
+ input[2] = (n+2 < size) ? buf[n+2] : 0;
+ output[0] = input[0] >> 2;
+ output[1] = ((input[0] & 3) << 4) + (input[1] >> 4);
+ output[2] = ((input[1] & 15) << 2) + (input[2] >> 6);
+ output[3] = input[2] & 63;
+ outbuf[m++] = base64_str[(int)output[0]];
+ outbuf[m++] = base64_str[(int)output[1]];
+ outbuf[m++] = (n+1 < size) ? base64_str[(int)output[2]] : base64_pad;
+ outbuf[m++] = (n+2 < size) ? base64_str[(int)output[3]] : base64_pad;
+ n+=3;
+ }
+ outbuf[m] = 0; // 0-termination!
+ return outbuf;
+}
+
static int indent_level = 0;
static int is_domain_known(char *domain)
@@ -121,7 +152,7 @@ static void plist_node_to_string(plist_t node)
double d;
uint8_t b;
uint64_t u = 0;
- GTimeVal tv = { 0, 0 };
+ struct timeval tv = { 0, 0 };
plist_type t;
@@ -161,10 +192,14 @@ static void plist_node_to_string(plist_t node)
case PLIST_DATA:
plist_get_data_val(node, &data, &u);
if (u > 0) {
- s = g_base64_encode((guchar *)data, u);
+ s = base64encode((unsigned char*)data, u);
free(data);
- printf("%s\n", s);
- g_free(s);
+ if (s) {
+ printf("%s\n", s);
+ free(s);
+ } else {
+ printf("\n");
+ }
} else {
printf("\n");
}
@@ -172,9 +207,24 @@ static void plist_node_to_string(plist_t node)
case PLIST_DATE:
plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec);
- s = g_time_val_to_iso8601(&tv);
- printf("%s\n", s);
- free(s);
+ {
+ time_t ti = (time_t)tv.tv_sec;
+ struct tm *btime = localtime(&ti);
+ if (btime) {
+ s = (char*)malloc(24);
+ memset(s, 0, 24);
+ if (strftime(s, 24, "%Y-%m-%dT%H:%M:%SZ", btime) <= 0) {
+ free (s);
+ s = NULL;
+ }
+ }
+ }
+ if (s) {
+ printf("%s\n", s);
+ free(s);
+ } else {
+ printf("\n");
+ }
break;
case PLIST_ARRAY:
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index b9676b9..9eebc5c 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -148,9 +148,10 @@ int main(int argc, char **argv)
userpref_get_paired_uuids(&uuids, &count);
for (i = 0; i < count; i++) {
printf("%s\n", uuids[i]);
+ free(uuids[i]);
}
if (uuids)
- g_strfreev(uuids);
+ free(uuids);
if (uuid)
free(uuid);
return EXIT_SUCCESS;
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 30e0c55..05e614f 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -24,7 +24,6 @@
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
-#include <glib.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -123,7 +122,7 @@ int main(int argc, char *argv[])
break;
}
- datalen = GUINT32_FROM_BE(datalen);
+ datalen = be32toh(datalen);
if (datalen == 0)
continue;