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 @@
-all:
+all: static
@echo "Please choose either macosx, linux, or windows"
+static:
+ gcc -o libirecovery.o -c src/libirecovery.c -g -I./include
+ ar rs libirecovery.a libirecovery.o
+ gcc -o irecovery src/irecovery.c -g -I./include -L. -lirecovery -lreadline -lusb-1.0
+
linux:
gcc -o libirecovery.o -c src/libirecovery.c -g -I./include -lreadline -fPIC
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) {
}
int irecv_reset(irecv_device* device) {
- if (device != NULL) {
- if (device->handle != NULL) {
- libusb_reset_device(device->handle);
- }
+ if (device == NULL || device->handle != NULL) {
+ return IRECV_ERROR_NO_DEVICE;
}
+ libusb_reset_device(device->handle);
return IRECV_SUCCESS;
}
int irecv_close(irecv_device* device) {
- if (device != NULL) {
- if (device->handle != NULL) {
- libusb_close(device->handle);
- device->handle = NULL;
- }
+ if (device == NULL || device->handle != NULL) {
+ return IRECV_ERROR_NO_DEVICE;
}
+ libusb_close(device->handle);
+ device->handle = NULL;
return IRECV_SUCCESS;
}