diff options
author | Nikias Bassen | 2021-09-01 15:48:32 +0200 |
---|---|---|
committer | Nikias Bassen | 2021-09-01 15:48:32 +0200 |
commit | ce7609375646cfb1e7d490579e172c37c74a0589 (patch) | |
tree | 0e0855e3c3971fc831c1378c35169990fb21cb13 /tools | |
parent | 24abbb9450c723617e10a6843978aa04a576523e (diff) | |
download | libimobiledevice-ce7609375646cfb1e7d490579e172c37c74a0589.tar.gz libimobiledevice-ce7609375646cfb1e7d490579e172c37c74a0589.tar.bz2 |
Remove common code in favor of new libimobiledevice-glue
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 54 | ||||
-rw-r--r-- | tools/idevicebackup.c | 2 | ||||
-rw-r--r-- | tools/idevicebackup2.c | 2 | ||||
-rw-r--r-- | tools/idevicecrashreport.c | 2 | ||||
-rw-r--r-- | tools/idevicedebugserverproxy.c | 4 | ||||
-rw-r--r-- | tools/ideviceimagemounter.c | 2 | ||||
-rw-r--r-- | tools/ideviceinfo.c | 2 | ||||
-rw-r--r-- | tools/ideviceprovision.c | 2 | ||||
-rw-r--r-- | tools/idevicesyslog.c | 92 |
9 files changed, 47 insertions, 115 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index b78f3f2..354cf1c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -31,9 +31,9 @@ bin_PROGRAMS = \ idevicesetlocation ideviceinfo_SOURCES = ideviceinfo.c -ideviceinfo_CFLAGS = $(AM_CFLAGS) -ideviceinfo_LDFLAGS = $(AM_LDFLAGS) -ideviceinfo_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +ideviceinfo_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +ideviceinfo_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +ideviceinfo_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicename_SOURCES = idevicename.c idevicename_CFLAGS = $(AM_CFLAGS) @@ -41,13 +41,13 @@ idevicename_LDFLAGS = $(AM_LDFLAGS) idevicename_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicepair_SOURCES = idevicepair.c -idevicepair_CFLAGS = -I$(top_srcdir) $(AM_CFLAGS) $(ssl_lib_CFLAGS) +idevicepair_CFLAGS = $(AM_CFLAGS) $(ssl_lib_CFLAGS) idevicepair_LDFLAGS = $(AM_LDFLAGS) $(libusbmuxd_LIBS) $(ssl_lib_LIBS) idevicepair_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la idevicesyslog_SOURCES = idevicesyslog.c -idevicesyslog_CFLAGS = $(AM_CFLAGS) -idevicesyslog_LDFLAGS = $(AM_LDFLAGS) +idevicesyslog_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +idevicesyslog_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) idevicesyslog_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevice_id_SOURCES = idevice_id.c @@ -56,19 +56,19 @@ idevice_id_LDFLAGS = $(AM_LDFLAGS) idevice_id_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicebackup_SOURCES = idevicebackup.c -idevicebackup_CFLAGS = $(AM_CFLAGS) $(ssl_lib_CFLAGS) -idevicebackup_LDFLAGS = $(AM_LDFLAGS) $(ssl_lib_LIBS) -idevicebackup_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +idevicebackup_CFLAGS = $(AM_CFLAGS) $(ssl_lib_CFLAGS) $(limd_glue_CFLAGS) +idevicebackup_LDFLAGS = $(AM_LDFLAGS) $(ssl_lib_LIBS) $(limd_glue_LIBS) +idevicebackup_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicebackup2_SOURCES = idevicebackup2.c -idevicebackup2_CFLAGS = $(AM_CFLAGS) -idevicebackup2_LDFLAGS = $(AM_LDFLAGS) -idevicebackup2_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +idevicebackup2_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +idevicebackup2_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +idevicebackup2_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la ideviceimagemounter_SOURCES = ideviceimagemounter.c -ideviceimagemounter_CFLAGS = $(AM_CFLAGS) -ideviceimagemounter_LDFLAGS = $(AM_LDFLAGS) -ideviceimagemounter_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +ideviceimagemounter_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +ideviceimagemounter_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +ideviceimagemounter_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicescreenshot_SOURCES = idevicescreenshot.c idevicescreenshot_CFLAGS = $(AM_CFLAGS) @@ -86,14 +86,14 @@ idevicedate_LDFLAGS = $(AM_LDFLAGS) idevicedate_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la ideviceprovision_SOURCES = ideviceprovision.c -ideviceprovision_CFLAGS = $(AM_CFLAGS) -ideviceprovision_LDFLAGS = $(AM_LDFLAGS) -ideviceprovision_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +ideviceprovision_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +ideviceprovision_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +ideviceprovision_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c -idevicedebugserverproxy_CFLAGS = -I$(top_srcdir) $(AM_CFLAGS) -idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS) -idevicedebugserverproxy_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +idevicedebugserverproxy_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicediagnostics_SOURCES = idevicediagnostics.c idevicediagnostics_CFLAGS = $(AM_CFLAGS) @@ -101,8 +101,8 @@ idevicediagnostics_LDFLAGS = $(AM_LDFLAGS) idevicediagnostics_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicedebug_SOURCES = idevicedebug.c -idevicedebug_CFLAGS = $(AM_CFLAGS) -idevicedebug_LDFLAGS = $(AM_LDFLAGS) +idevicedebug_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +idevicedebug_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) idevicedebug_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la idevicenotificationproxy_SOURCES = idevicenotificationproxy.c @@ -111,11 +111,11 @@ idevicenotificationproxy_LDFLAGS = $(AM_LDFLAGS) idevicenotificationproxy_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicecrashreport_SOURCES = idevicecrashreport.c -idevicecrashreport_CFLAGS = -I$(top_srcdir) $(AM_CFLAGS) -idevicecrashreport_LDFLAGS = $(AM_LDFLAGS) -idevicecrashreport_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +idevicecrashreport_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS) +idevicecrashreport_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS) +idevicecrashreport_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la idevicesetlocation_SOURCES = idevicesetlocation.c idevicesetlocation_CFLAGS = $(AM_CFLAGS) idevicesetlocation_LDFLAGS = $(AM_LDFLAGS) -idevicesetlocation_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la +idevicesetlocation_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 8d0f74b..42f020d 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -55,7 +55,7 @@ #include <libimobiledevice/mobilebackup.h> #include <libimobiledevice/notification_proxy.h> #include <libimobiledevice/afc.h> -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> #define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup" #define NP_SERVICE_NAME "com.apple.mobile.notification_proxy" diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 6ed852f..7c8503e 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -45,7 +45,7 @@ #include <libimobiledevice/installation_proxy.h> #include <libimobiledevice/sbservices.h> #include <libimobiledevice/diagnostics_relay.h> -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> #include <endianness.h> diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c index 0a03c68..4d3b686 100644 --- a/tools/idevicecrashreport.c +++ b/tools/idevicecrashreport.c @@ -33,7 +33,7 @@ #ifndef WIN32 #include <signal.h> #endif -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c index 15e8deb..b190f63 100644 --- a/tools/idevicedebugserverproxy.c +++ b/tools/idevicedebugserverproxy.c @@ -41,8 +41,8 @@ #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/debugserver.h> -#include "common/socket.h" -#include "common/thread.h" +#include <libimobiledevice-glue/socket.h> +#include <libimobiledevice-glue/thread.h> #define info(...) fprintf(stdout, __VA_ARGS__); fflush(stdout) #define debug(...) if(debug_mode) fprintf(stdout, __VA_ARGS__) diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index 325a9e2..37c2154 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c @@ -46,7 +46,7 @@ #include <libimobiledevice/notification_proxy.h> #include <libimobiledevice/mobile_image_mounter.h> #include <asprintf.h> -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> static int list_mode = 0; static int use_network = 0; diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c index 97ae03a..54ae1d2 100644 --- a/tools/ideviceinfo.c +++ b/tools/ideviceinfo.c @@ -37,7 +37,7 @@ #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> #define FORMAT_KEY_VALUE 1 #define FORMAT_XML 2 diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c index c93a682..36c69b0 100644 --- a/tools/ideviceprovision.c +++ b/tools/ideviceprovision.c @@ -44,7 +44,7 @@ #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> #include <libimobiledevice/misagent.h> -#include "common/utils.h" +#include <libimobiledevice-glue/utils.h> static void print_usage(int argc, char **argv) { diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index d9b627f..4eb1605 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c @@ -41,10 +41,10 @@ #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/syslog_relay.h> +#include <libimobiledevice-glue/termcolors.h> static int quit_flag = 0; static int exit_on_disconnect = 0; -static int use_colors = 0; static int show_device_name = 0; static char* udid = NULL; @@ -75,58 +75,6 @@ static char *line = NULL; static int line_buffer_size = 0; static int lp = 0; -#ifdef WIN32 -static WORD COLOR_RESET = 0; -static HANDLE h_stdout = INVALID_HANDLE_VALUE; - -#define COLOR_NORMAL COLOR_RESET -#define COLOR_DARK FOREGROUND_INTENSITY -#define COLOR_RED FOREGROUND_RED |FOREGROUND_INTENSITY -#define COLOR_DARK_RED FOREGROUND_RED -#define COLOR_GREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY -#define COLOR_DARK_GREEN FOREGROUND_GREEN -#define COLOR_YELLOW FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY -#define COLOR_DARK_YELLOW FOREGROUND_GREEN | FOREGROUND_RED -#define COLOR_BLUE FOREGROUND_BLUE | FOREGROUND_INTENSITY -#define COLOR_DARK_BLUE FOREGROUND_BLUE -#define COLOR_MAGENTA FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY -#define COLOR_DARK_MAGENTA FOREGROUND_BLUE | FOREGROUND_RED -#define COLOR_CYAN FOREGROUND_BLUE | FOREGROUND_GREEN -#define COLOR_BRIGHT_CYAN FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY -#define COLOR_DARK_CYAN FOREGROUND_BLUE | FOREGROUND_GREEN -#define COLOR_WHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY -#define COLOR_DARK_WHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE - -static void TEXT_COLOR(WORD attr) -{ - if (use_colors) { - SetConsoleTextAttribute(h_stdout, attr); - } -} -#else - -#define COLOR_RESET "\e[m" -#define COLOR_NORMAL "\e[0m" -#define COLOR_DARK "\e[2m" -#define COLOR_RED "\e[0;31m" -#define COLOR_DARK_RED "\e[2;31m" -#define COLOR_GREEN "\e[0;32m" -#define COLOR_DARK_GREEN "\e[2;32m" -#define COLOR_YELLOW "\e[0;33m" -#define COLOR_DARK_YELLOW "\e[2;33m" -#define COLOR_BLUE "\e[0;34m" -#define COLOR_DARK_BLUE "\e[2;34m" -#define COLOR_MAGENTA "\e[0;35m" -#define COLOR_DARK_MAGENTA "\e[2;35m" -#define COLOR_CYAN "\e[0;36m" -#define COLOR_BRIGHT_CYAN "\e[1;36m" -#define COLOR_DARK_CYAN "\e[2;36m" -#define COLOR_WHITE "\e[1;37m" -#define COLOR_DARK_WHITE "\e[0;37m" - -#define TEXT_COLOR(x) if (use_colors) { fwrite(x, 1, sizeof(x)-1, stdout); } -#endif - static void add_filter(const char* filterstr) { int filter_len = strlen(filterstr); @@ -201,7 +149,7 @@ static void syslog_callback(char c, void *user_data) do { if (lp < 16) { shall_print = 1; - TEXT_COLOR(COLOR_WHITE); + cprintf(COLOR_WHITE); break; } else if (line[3] == ' ' && line[6] == ' ' && line[15] == ' ') { char* end = &line[lp]; @@ -331,11 +279,7 @@ static void syslog_callback(char c, void *user_data) /* log level */ char* level_start = p; char* level_end = p; -#ifdef WIN32 - WORD level_color = COLOR_NORMAL; -#else const char* level_color = NULL; -#endif if (!strncmp(p, "<Notice>:", 9)) { level_end += 9; level_color = COLOR_GREEN; @@ -353,24 +297,24 @@ static void syslog_callback(char c, void *user_data) } /* write date and time */ - TEXT_COLOR(COLOR_DARK_WHITE); + cprintf(COLOR_LIGHT_GRAY); fwrite(line, 1, 16, stdout); if (show_device_name) { /* write device name */ - TEXT_COLOR(COLOR_DARK_YELLOW); + cprintf(COLOR_DARK_YELLOW); fwrite(device_name_start, 1, device_name_end-device_name_start+1, stdout); - TEXT_COLOR(COLOR_RESET); + cprintf(COLOR_RESET); } /* write process name */ - TEXT_COLOR(COLOR_BRIGHT_CYAN); + cprintf(COLOR_BRIGHT_CYAN); fwrite(process_name_start, 1, process_name_end-process_name_start, stdout); - TEXT_COLOR(COLOR_CYAN); + cprintf(COLOR_CYAN); fwrite(process_name_end, 1, proc_name_end-process_name_end+1, stdout); /* write log level */ - TEXT_COLOR(level_color); + cprintf(level_color); if (level_end > level_start) { fwrite(level_start, 1, level_end-level_start, stdout); p = level_end; @@ -379,17 +323,17 @@ static void syslog_callback(char c, void *user_data) lp -= p - linep; linep = p; - TEXT_COLOR(COLOR_WHITE); + cprintf(COLOR_WHITE); } else { shall_print = 1; - TEXT_COLOR(COLOR_WHITE); + cprintf(COLOR_WHITE); } } while (0); if ((num_msg_filters == 0 && num_proc_filters == 0 && num_pid_filters == 0 && num_trigger_filters == 0 && num_untrigger_filters == 0) || shall_print) { fwrite(linep, 1, lp, stdout); - TEXT_COLOR(COLOR_RESET); + cprintf(COLOR_RESET); fflush(stdout); if (trigger_off) { triggered = 0; @@ -560,14 +504,6 @@ static void print_usage(int argc, char **argv, int is_error) int main(int argc, char *argv[]) { -#ifdef WIN32 - CONSOLE_SCREEN_BUFFER_INFO csbi; - h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); - if (GetConsoleScreenBufferInfo(h_stdout, &csbi)) { - COLOR_RESET = csbi.wAttributes; - } -#endif - int no_colors = 0; int include_filter = 0; int exclude_filter = 0; int include_kernel = 0; @@ -700,7 +636,7 @@ int main(int argc, char *argv[]) return 0; } case 2: - no_colors = 1; + term_colors_set_enabled(0); break; case 'v': printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); @@ -756,10 +692,6 @@ int main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!no_colors && isatty(1)) { - use_colors = 1; - } - int num = 0; idevice_info_t *devices = NULL; idevice_get_device_list_extended(&devices, &num); |