summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-09-26 23:54:06 +0200
committerGravatar Martin Szulecki2013-09-26 23:54:06 +0200
commit9a28cfe084b9cf04c0170dce8821356638d50b38 (patch)
tree1b581021f494f654f2faff423248d0144c7e3e0c
parent4afbb1aec79b3f80c55b3156475bdf546461464d (diff)
downloadlibirecovery-9a28cfe084b9cf04c0170dce8821356638d50b38.tar.gz
libirecovery-9a28cfe084b9cf04c0170dce8821356638d50b38.tar.bz2
Rename device struct fields and provide device database getters for them
-rw-r--r--include/libirecovery.h6
-rw-r--r--src/libirecovery.c38
-rw-r--r--tools/irecovery.c2
3 files changed, 39 insertions, 7 deletions
diff --git a/include/libirecovery.h b/include/libirecovery.h
index a405005..152634f 100644
--- a/include/libirecovery.h
+++ b/include/libirecovery.h
@@ -68,8 +68,8 @@ typedef struct {
} irecv_event_t;
struct irecv_device {
- const char* product;
- const char* model;
+ const char* product_type;
+ const char* hardware_model;
unsigned int board_id;
unsigned int chip_id;
};
@@ -132,6 +132,8 @@ irecv_error_t irecv_get_imei(irecv_client_t client, char* imei);
/* device database queries */
irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_device_t* device);
+irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device);
+irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device);
#ifdef __cplusplus
}
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 1429237..7aeb205 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -1519,14 +1519,44 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de
return IRECV_E_UNKNOWN_ERROR;
}
- for (i = 0; irecv_devices[i].model != NULL; i++) {
+ for (i = 0; irecv_devices[i].hardware_model != NULL; i++) {
if (irecv_devices[i].chip_id == cpid && irecv_devices[i].board_id == bdid) {
- device_id = irecv_devices[i].index;
+ *device = &irecv_devices[i];
+ return IRECV_E_SUCCESS;
}
}
- *device = &irecv_devices[device_id];
- return IRECV_E_SUCCESS;
+ return IRECV_E_NO_DEVICE;
+}
+
+irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device) {
+ int i = 0;
+
+ *device = NULL;
+
+ for (i = 0; irecv_devices[i].product_type != NULL; i++) {
+ if (!strcmp(product_type, irecv_devices[i].product_type)) {
+ *device = &irecv_devices[i];
+ return IRECV_E_SUCCESS;
+ }
+ }
+
+ return IRECV_E_NO_DEVICE;
+}
+
+irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device) {
+ int i = 0;
+
+ *device = NULL;
+
+ for (i = 0; irecv_devices[i].hardware_model != NULL; i++) {
+ if (!strcmp(hardware_model, irecv_devices[i].hardware_model)) {
+ *device = &irecv_devices[i];
+ return IRECV_E_SUCCESS;
+ }
+ }
+
+ return IRECV_E_NO_DEVICE;
}
irecv_client_t irecv_reconnect(irecv_client_t client, int initial_pause) {
diff --git a/tools/irecovery.c b/tools/irecovery.c
index 32e9f9f..c4d6dce 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -347,7 +347,7 @@ int main(int argc, char* argv[]) {
irecv_device_t device = NULL;
irecv_devices_get_device_by_client(client, &device);
if (device)
- debug("Connected to %s, model %s, cpid 0x%04x, bdid 0x%02x\n", device->product, device->model, device->chip_id, device->board_id);
+ debug("Connected to %s, model %s, cpid 0x%04x, bdid 0x%02x\n", device->product_type, device->hardware_model, device->chip_id, device->board_id);
switch (action) {
case kResetDevice: