summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--src/libirecovery.c16
2 files changed, 13 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index a2074a7..2d7cc8e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,11 @@
1all: 1all: static
2 @echo "Please choose either macosx, linux, or windows" 2 @echo "Please choose either macosx, linux, or windows"
3 3
4static:
5 gcc -o libirecovery.o -c src/libirecovery.c -g -I./include
6 ar rs libirecovery.a libirecovery.o
7 gcc -o irecovery src/irecovery.c -g -I./include -L. -lirecovery -lreadline -lusb-1.0
8
4linux: 9linux:
5 gcc -o libirecovery.o -c src/libirecovery.c -g -I./include -lreadline -fPIC 10 gcc -o libirecovery.o -c src/libirecovery.c -g -I./include -lreadline -fPIC
6 gcc -o libirecovery.so libirecovery.o -g -shared -Wl,-soname,libirecovery.so -lusb-1.0 11 gcc -o libirecovery.so libirecovery.o -g -shared -Wl,-soname,libirecovery.so -lusb-1.0
diff --git a/src/libirecovery.c b/src/libirecovery.c
index cdb0c53..a5b5c84 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -79,23 +79,21 @@ int irecv_open(irecv_device* device) {
79} 79}
80 80
81int irecv_reset(irecv_device* device) { 81int irecv_reset(irecv_device* device) {
82 if (device != NULL) { 82 if (device == NULL || device->handle != NULL) {
83 if (device->handle != NULL) { 83 return IRECV_ERROR_NO_DEVICE;
84 libusb_reset_device(device->handle);
85 }
86 } 84 }
87 85
86 libusb_reset_device(device->handle);
88 return IRECV_SUCCESS; 87 return IRECV_SUCCESS;
89} 88}
90 89
91int irecv_close(irecv_device* device) { 90int irecv_close(irecv_device* device) {
92 if (device != NULL) { 91 if (device == NULL || device->handle != NULL) {
93 if (device->handle != NULL) { 92 return IRECV_ERROR_NO_DEVICE;
94 libusb_close(device->handle);
95 device->handle = NULL;
96 }
97 } 93 }
98 94
95 libusb_close(device->handle);
96 device->handle = NULL;
99 return IRECV_SUCCESS; 97 return IRECV_SUCCESS;
100} 98}
101 99