diff options
| author | 2011-09-03 02:10:48 +0200 | |
|---|---|---|
| committer | 2012-03-18 20:40:54 +0100 | |
| commit | dcb85727c3649c254c985d840aa2efb36f727872 (patch) | |
| tree | 0f6f551b70bd845f57d5a044915e617a1bd40ac6 /tools | |
| parent | 6a83ef58a1032e3b336587e2f3a19659ae325c25 (diff) | |
| download | libimobiledevice-dcb85727c3649c254c985d840aa2efb36f727872.tar.gz libimobiledevice-dcb85727c3649c254c985d840aa2efb36f727872.tar.bz2 | |
Completely remove glib dependency.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Makefile.am | 18 | ||||
| -rw-r--r-- | tools/ideviceimagemounter.c | 25 | ||||
| -rw-r--r-- | tools/ideviceinfo.c | 66 | ||||
| -rw-r--r-- | tools/idevicepair.c | 3 | ||||
| -rw-r--r-- | tools/idevicesyslog.c | 3 |
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 @@ | |||
| 1 | AM_CPPFLAGS = -I$(top_srcdir)/include | 1 | AM_CPPFLAGS = -I$(top_srcdir)/include |
| 2 | 2 | ||
| 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) | 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(LFS_CFLAGS) |
| 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(libgnutls_LIBS) $(libtasn1_LIBS) |
| 5 | 5 | ||
| 6 | bin_PROGRAMS = idevice_id ideviceinfo idevicepair idevicesyslog idevicebackup idevicebackup2 ideviceimagemounter idevicescreenshot ideviceenterrecovery idevicedate | 6 | bin_PROGRAMS = idevice_id ideviceinfo idevicepair idevicesyslog ideviceimagemounter idevicescreenshot ideviceenterrecovery idevicedate |
| 7 | |||
| 8 | if HAVE_GLIB2 | ||
| 9 | bin_PROGRAMS += idevicebackup idevicebackup2 | ||
| 10 | endif | ||
| 7 | 11 | ||
| 8 | ideviceinfo_SOURCES = ideviceinfo.c | 12 | ideviceinfo_SOURCES = ideviceinfo.c |
| 9 | ideviceinfo_CFLAGS = $(AM_CFLAGS) | 13 | ideviceinfo_CFLAGS = $(AM_CFLAGS) |
| @@ -26,13 +30,13 @@ idevice_id_LDFLAGS = $(AM_LDFLAGS) | |||
| 26 | idevice_id_LDADD = ../src/libimobiledevice.la | 30 | idevice_id_LDADD = ../src/libimobiledevice.la |
| 27 | 31 | ||
| 28 | idevicebackup_SOURCES = idevicebackup.c | 32 | idevicebackup_SOURCES = idevicebackup.c |
| 29 | idevicebackup_CFLAGS = $(AM_CFLAGS) | 33 | idevicebackup_CFLAGS = $(AM_CFLAGS) $(libglib2_CFLAGS) |
| 30 | idevicebackup_LDFLAGS = $(AM_LDFLAGS) | 34 | idevicebackup_LDFLAGS = $(AM_LDFLAGS) $(libglib2_LIBS) |
| 31 | idevicebackup_LDADD = ../src/libimobiledevice.la | 35 | idevicebackup_LDADD = ../src/libimobiledevice.la |
| 32 | 36 | ||
| 33 | idevicebackup2_SOURCES = idevicebackup2.c | 37 | idevicebackup2_SOURCES = idevicebackup2.c |
| 34 | idevicebackup2_CFLAGS = $(AM_CFLAGS) | 38 | idevicebackup2_CFLAGS = $(AM_CFLAGS) $(libglib2_CFLAGS) |
| 35 | idevicebackup2_LDFLAGS = $(AM_LDFLAGS) | 39 | idevicebackup2_LDFLAGS = $(AM_LDFLAGS) $(libglib2_LIBS) |
| 36 | idevicebackup2_LDADD = ../src/libimobiledevice.la | 40 | idevicebackup2_LDADD = ../src/libimobiledevice.la |
| 37 | 41 | ||
| 38 | ideviceimagemounter_SOURCES = ideviceimagemounter.c | 42 | 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 @@ | |||
| 28 | #include <string.h> | 28 | #include <string.h> |
| 29 | #include <getopt.h> | 29 | #include <getopt.h> |
| 30 | #include <errno.h> | 30 | #include <errno.h> |
| 31 | #include <glib.h> | ||
| 32 | #include <libgen.h> | 31 | #include <libgen.h> |
| 32 | #include <time.h> | ||
| 33 | #include <sys/time.h> | ||
| 33 | 34 | ||
| 34 | #include <libimobiledevice/libimobiledevice.h> | 35 | #include <libimobiledevice/libimobiledevice.h> |
| 35 | #include <libimobiledevice/lockdown.h> | 36 | #include <libimobiledevice/lockdown.h> |
| @@ -165,7 +166,7 @@ static void plist_node_to_string(plist_t node) | |||
| 165 | double d; | 166 | double d; |
| 166 | uint8_t b; | 167 | uint8_t b; |
| 167 | uint64_t u = 0; | 168 | uint64_t u = 0; |
| 168 | GTimeVal tv = { 0, 0 }; | 169 | struct timeval tv = { 0, 0 }; |
| 169 | 170 | ||
| 170 | plist_type t; | 171 | plist_type t; |
| 171 | 172 | ||
| @@ -214,9 +215,23 @@ static void plist_node_to_string(plist_t node) | |||
| 214 | 215 | ||
| 215 | case PLIST_DATE: | 216 | case PLIST_DATE: |
| 216 | plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec); | 217 | plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec); |
| 217 | s = g_time_val_to_iso8601(&tv); | 218 | { |
| 218 | printf("%s\n", s); | 219 | time_t ti = (time_t)tv.tv_sec; |
| 219 | free(s); | 220 | struct tm *btime = localtime(&ti); |
| 221 | if (btime) { | ||
| 222 | s = (char*)malloc(24); | ||
| 223 | memset(s, 0, 24); | ||
| 224 | if (strftime(s, 24, "%Y-%m-%dT%H:%M:%SZ", btime) <= 0) { | ||
| 225 | free (s); | ||
| 226 | s = NULL; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | } | ||
| 230 | if (s) { | ||
| 231 | puts(s); | ||
| 232 | free(s); | ||
| 233 | } | ||
| 234 | puts("\n"); | ||
| 220 | break; | 235 | break; |
| 221 | 236 | ||
| 222 | case PLIST_ARRAY: | 237 | 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 @@ | |||
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
| 26 | #include <glib.h> | 26 | #include <time.h> |
| 27 | #include <sys/time.h> | ||
| 27 | 28 | ||
| 28 | #include <libimobiledevice/libimobiledevice.h> | 29 | #include <libimobiledevice/libimobiledevice.h> |
| 29 | #include <libimobiledevice/lockdown.h> | 30 | #include <libimobiledevice/lockdown.h> |
| @@ -58,6 +59,36 @@ static const char *domains[] = { | |||
| 58 | NULL | 59 | NULL |
| 59 | }; | 60 | }; |
| 60 | 61 | ||
| 62 | static const char base64_str[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| 63 | static const char base64_pad = '='; | ||
| 64 | |||
| 65 | static char *base64encode(const unsigned char *buf, size_t size) | ||
| 66 | { | ||
| 67 | if (!buf || !(size > 0)) return NULL; | ||
| 68 | int outlen = (size / 3) * 4; | ||
| 69 | char *outbuf = (char*)malloc(outlen+5); // 4 spare bytes + 1 for '\0' | ||
| 70 | size_t n = 0; | ||
| 71 | size_t m = 0; | ||
| 72 | unsigned char input[3]; | ||
| 73 | unsigned int output[4]; | ||
| 74 | while (n < size) { | ||
| 75 | input[0] = buf[n]; | ||
| 76 | input[1] = (n+1 < size) ? buf[n+1] : 0; | ||
| 77 | input[2] = (n+2 < size) ? buf[n+2] : 0; | ||
| 78 | output[0] = input[0] >> 2; | ||
| 79 | output[1] = ((input[0] & 3) << 4) + (input[1] >> 4); | ||
| 80 | output[2] = ((input[1] & 15) << 2) + (input[2] >> 6); | ||
| 81 | output[3] = input[2] & 63; | ||
| 82 | outbuf[m++] = base64_str[(int)output[0]]; | ||
| 83 | outbuf[m++] = base64_str[(int)output[1]]; | ||
| 84 | outbuf[m++] = (n+1 < size) ? base64_str[(int)output[2]] : base64_pad; | ||
| 85 | outbuf[m++] = (n+2 < size) ? base64_str[(int)output[3]] : base64_pad; | ||
| 86 | n+=3; | ||
| 87 | } | ||
| 88 | outbuf[m] = 0; // 0-termination! | ||
| 89 | return outbuf; | ||
| 90 | } | ||
| 91 | |||
| 61 | static int indent_level = 0; | 92 | static int indent_level = 0; |
| 62 | 93 | ||
| 63 | static int is_domain_known(char *domain) | 94 | static int is_domain_known(char *domain) |
| @@ -121,7 +152,7 @@ static void plist_node_to_string(plist_t node) | |||
| 121 | double d; | 152 | double d; |
| 122 | uint8_t b; | 153 | uint8_t b; |
| 123 | uint64_t u = 0; | 154 | uint64_t u = 0; |
| 124 | GTimeVal tv = { 0, 0 }; | 155 | struct timeval tv = { 0, 0 }; |
| 125 | 156 | ||
| 126 | plist_type t; | 157 | plist_type t; |
| 127 | 158 | ||
| @@ -161,10 +192,14 @@ static void plist_node_to_string(plist_t node) | |||
| 161 | case PLIST_DATA: | 192 | case PLIST_DATA: |
| 162 | plist_get_data_val(node, &data, &u); | 193 | plist_get_data_val(node, &data, &u); |
| 163 | if (u > 0) { | 194 | if (u > 0) { |
| 164 | s = g_base64_encode((guchar *)data, u); | 195 | s = base64encode((unsigned char*)data, u); |
| 165 | free(data); | 196 | free(data); |
| 166 | printf("%s\n", s); | 197 | if (s) { |
| 167 | g_free(s); | 198 | printf("%s\n", s); |
| 199 | free(s); | ||
| 200 | } else { | ||
| 201 | printf("\n"); | ||
| 202 | } | ||
| 168 | } else { | 203 | } else { |
| 169 | printf("\n"); | 204 | printf("\n"); |
| 170 | } | 205 | } |
| @@ -172,9 +207,24 @@ static void plist_node_to_string(plist_t node) | |||
| 172 | 207 | ||
| 173 | case PLIST_DATE: | 208 | case PLIST_DATE: |
| 174 | plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec); | 209 | plist_get_date_val(node, (int32_t*)&tv.tv_sec, (int32_t*)&tv.tv_usec); |
| 175 | s = g_time_val_to_iso8601(&tv); | 210 | { |
| 176 | printf("%s\n", s); | 211 | time_t ti = (time_t)tv.tv_sec; |
| 177 | free(s); | 212 | struct tm *btime = localtime(&ti); |
| 213 | if (btime) { | ||
| 214 | s = (char*)malloc(24); | ||
| 215 | memset(s, 0, 24); | ||
| 216 | if (strftime(s, 24, "%Y-%m-%dT%H:%M:%SZ", btime) <= 0) { | ||
| 217 | free (s); | ||
| 218 | s = NULL; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | } | ||
| 222 | if (s) { | ||
| 223 | printf("%s\n", s); | ||
| 224 | free(s); | ||
| 225 | } else { | ||
| 226 | printf("\n"); | ||
| 227 | } | ||
| 178 | break; | 228 | break; |
| 179 | 229 | ||
| 180 | case PLIST_ARRAY: | 230 | 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) | |||
| 148 | userpref_get_paired_uuids(&uuids, &count); | 148 | userpref_get_paired_uuids(&uuids, &count); |
| 149 | for (i = 0; i < count; i++) { | 149 | for (i = 0; i < count; i++) { |
| 150 | printf("%s\n", uuids[i]); | 150 | printf("%s\n", uuids[i]); |
| 151 | free(uuids[i]); | ||
| 151 | } | 152 | } |
| 152 | if (uuids) | 153 | if (uuids) |
| 153 | g_strfreev(uuids); | 154 | free(uuids); |
| 154 | if (uuid) | 155 | if (uuid) |
| 155 | free(uuid); | 156 | free(uuid); |
| 156 | return EXIT_SUCCESS; | 157 | 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 @@ | |||
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <signal.h> | 25 | #include <signal.h> |
| 26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
| 27 | #include <glib.h> | ||
| 28 | 27 | ||
| 29 | #include <libimobiledevice/libimobiledevice.h> | 28 | #include <libimobiledevice/libimobiledevice.h> |
| 30 | #include <libimobiledevice/lockdown.h> | 29 | #include <libimobiledevice/lockdown.h> |
| @@ -123,7 +122,7 @@ int main(int argc, char *argv[]) | |||
| 123 | break; | 122 | break; |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 126 | datalen = GUINT32_FROM_BE(datalen); | 125 | datalen = be32toh(datalen); |
| 127 | 126 | ||
| 128 | if (datalen == 0) | 127 | if (datalen == 0) |
| 129 | continue; | 128 | continue; |
