diff options
| author | 2008-08-31 11:47:18 +0200 | |
|---|---|---|
| committer | 2008-08-31 19:33:19 +0200 | |
| commit | 86f61988990daa30c8564e2b26666dd442bd6e65 (patch) | |
| tree | 985400ee8848585dabf8efbe2acbfc37d9b3f2f8 /src/iphone.c | |
| parent | dc89741f00bd6919c0eedbd882c05f66d72fdbee (diff) | |
| download | libimobiledevice-86f61988990daa30c8564e2b26666dd442bd6e65.tar.gz libimobiledevice-86f61988990daa30c8564e2b26666dd442bd6e65.tar.bz2 | |
make all functions return an error code.
Diffstat (limited to 'src/iphone.c')
| -rw-r--r-- | src/iphone.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/iphone.c b/src/iphone.c index 3d179de..f5bc206 100644 --- a/src/iphone.c +++ b/src/iphone.c | |||
| @@ -34,7 +34,7 @@ extern int debug; | |||
| 34 | * @return A structure with data on the first iPhone it finds. (Or NULL, on | 34 | * @return A structure with data on the first iPhone it finds. (Or NULL, on |
| 35 | * error) | 35 | * error) |
| 36 | */ | 36 | */ |
| 37 | int iphone_get_device ( iphone_device_t *device ){ | 37 | iphone_error_t iphone_get_device ( iphone_device_t *device ){ |
| 38 | //check we can actually write in device | 38 | //check we can actually write in device |
| 39 | if (!device || (device && *device)) | 39 | if (!device || (device && *device)) |
| 40 | return IPHONE_E_INVALID_ARG; | 40 | return IPHONE_E_INVALID_ARG; |
| @@ -102,7 +102,7 @@ int iphone_get_device ( iphone_device_t *device ){ | |||
| 102 | iphone_free_device(phone); | 102 | iphone_free_device(phone); |
| 103 | if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n"); | 103 | if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n"); |
| 104 | if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n", | 104 | if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n", |
| 105 | bytes, usb_strerror(), strerror(-bytes)); | 105 | bytes, usb_strerror(), strerror(-bytes)); |
| 106 | return IPHONE_E_NOT_ENOUGH_DATA; | 106 | return IPHONE_E_NOT_ENOUGH_DATA; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| @@ -134,14 +134,21 @@ int iphone_get_device ( iphone_device_t *device ){ | |||
| 134 | * | 134 | * |
| 135 | * @param phone A pointer to an iPhone structure. | 135 | * @param phone A pointer to an iPhone structure. |
| 136 | */ | 136 | */ |
| 137 | void iphone_free_device ( iphone_device_t device ) { | 137 | iphone_error_t iphone_free_device ( iphone_device_t device ) { |
| 138 | if (device->buffer) free(device->buffer); | 138 | if (!device) return IPHONE_E_INVALID_ARG; |
| 139 | if (device->device) { | 139 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; |
| 140 | usb_release_interface(device->device, 1); | 140 | |
| 141 | usb_reset(device->device); | 141 | if (device->buffer) { |
| 142 | usb_close(device->device); | 142 | free(device->buffer); |
| 143 | if (device->device) { | ||
| 144 | usb_release_interface(device->device, 1); | ||
| 145 | usb_reset(device->device); | ||
| 146 | usb_close(device->device); | ||
| 147 | ret = IPHONE_E_SUCCESS; | ||
| 148 | } | ||
| 149 | free(device); | ||
| 143 | } | 150 | } |
| 144 | free(device); | 151 | return ret; |
| 145 | } | 152 | } |
| 146 | 153 | ||
| 147 | /** Sends data to the phone | 154 | /** Sends data to the phone |
