From 4daf6d84f7271cc19256c45b52c63b99ba7b4391 Mon Sep 17 00:00:00 2001
From: Nikias Bassen
Date: Mon, 17 Sep 2018 18:11:47 +0200
Subject: Add configuration option to allow compiling without USB driver

Using --with-dummy, libirecovery can be compiled in a way that it will
not require any USB driver at all. This is only useful if you just want
to query libirecovery's device database by product type or hardware model,
namely using:
    irecv_devices_get_device_by_product_type();
    irecv_devices_get_device_by_hardware_model();
All other function are either no-op or return IRECV_E_UNSUPPORTED
if the library is compiled this way.
---
 tools/irecovery.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'tools')

diff --git a/tools/irecovery.c b/tools/irecovery.c
index f250dc5..2db6f4f 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -459,12 +459,18 @@ int main(int argc, char* argv[]) {
 	for (i = 0; i <= 5; i++) {
 		debug("Attempting to connect... \n");
 
-		if (irecv_open_with_ecid(&client, ecid) != IRECV_E_SUCCESS)
+		irecv_error_t err = irecv_open_with_ecid(&client, ecid);
+		if (err == IRECV_E_UNSUPPORTED) {
+			fprintf(stderr, "ERROR: %s\n", irecv_strerror(err));
+			return -1;
+		}
+		else if (err != IRECV_E_SUCCESS)
 			sleep(1);
 		else
 			break;
 
 		if (i == 5) {
+			fprintf(stderr, "ERROR: %s\n", irecv_strerror(err));
 			return -1;
 		}
 	}
-- 
cgit v1.1-32-gdbae