summaryrefslogtreecommitdiffstats
path: root/src/iphone.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-31 11:47:18 +0200
committerGravatar Jonathan Beck2008-08-31 19:33:19 +0200
commit86f61988990daa30c8564e2b26666dd442bd6e65 (patch)
tree985400ee8848585dabf8efbe2acbfc37d9b3f2f8 /src/iphone.c
parentdc89741f00bd6919c0eedbd882c05f66d72fdbee (diff)
downloadlibimobiledevice-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.c25
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;
* @return A structure with data on the first iPhone it finds. (Or NULL, on
* error)
*/
-int iphone_get_device ( iphone_device_t *device ){
+iphone_error_t iphone_get_device ( iphone_device_t *device ){
//check we can actually write in device
if (!device || (device && *device))
return IPHONE_E_INVALID_ARG;
@@ -102,7 +102,7 @@ int iphone_get_device ( iphone_device_t *device ){
iphone_free_device(phone);
if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n");
if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n",
- bytes, usb_strerror(), strerror(-bytes));
+ bytes, usb_strerror(), strerror(-bytes));
return IPHONE_E_NOT_ENOUGH_DATA;
}
@@ -134,14 +134,21 @@ int iphone_get_device ( iphone_device_t *device ){
*
* @param phone A pointer to an iPhone structure.
*/
-void iphone_free_device ( iphone_device_t device ) {
- if (device->buffer) free(device->buffer);
- if (device->device) {
- usb_release_interface(device->device, 1);
- usb_reset(device->device);
- usb_close(device->device);
+iphone_error_t iphone_free_device ( iphone_device_t device ) {
+ if (!device) return IPHONE_E_INVALID_ARG;
+ iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
+
+ if (device->buffer) {
+ free(device->buffer);
+ if (device->device) {
+ usb_release_interface(device->device, 1);
+ usb_reset(device->device);
+ usb_close(device->device);
+ ret = IPHONE_E_SUCCESS;
+ }
+ free(device);
}
- free(device);
+ return ret;
}
/** Sends data to the phone