diff options
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | src/libirecovery.c | 16 |
2 files changed, 13 insertions, 10 deletions
| @@ -1,6 +1,11 @@ | |||
| 1 | all: | 1 | all: static |
| 2 | @echo "Please choose either macosx, linux, or windows" | 2 | @echo "Please choose either macosx, linux, or windows" |
| 3 | 3 | ||
| 4 | static: | ||
| 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 | |||
| 4 | linux: | 9 | linux: |
| 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 | ||
| 81 | int irecv_reset(irecv_device* device) { | 81 | int 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 | ||
| 91 | int irecv_close(irecv_device* device) { | 90 | int 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 | ||
