summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-02 22:12:59 -0400
committerGravatar Joshua Hill2010-06-02 22:12:59 -0400
commitac4f614856a5751336fdb1b29b33060bd6c2eaf1 (patch)
tree097a3063556de5a73d16298868a4dd16ecccd4cf /src/libirecovery.c
parent30fd56859f50dea5712492807a1b9784da9fec11 (diff)
downloadlibirecovery-ac4f614856a5751336fdb1b29b33060bd6c2eaf1.tar.gz
libirecovery-ac4f614856a5751336fdb1b29b33060bd6c2eaf1.tar.bz2
Added some new helper functions to fetch chip id and board id and changed Makefile to automatically refresh linker cache after install
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index a641562..1303fc5 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -393,6 +393,48 @@ irecv_error_t irecv_getenv(irecv_client_t client, unsigned char** var) {
return IRECV_E_SUCCESS;
}
+irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) {
+ char info[256];
+ memset(info, '\0', 256);
+
+ if (client == NULL || client->handle == NULL) {
+ return IRECV_E_NO_DEVICE;
+ }
+
+ libusb_get_string_descriptor_ascii(client->handle, 3, info, 255);
+ printf("%d: %s\n", strlen(info), info);
+
+ unsigned char* cpid_string = strstr(info, "CPID:");
+ if (cpid_string == NULL) {
+ *cpid = 0;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+ sscanf(cpid_string, "CPID:%d", cpid);
+
+ return IRECV_E_SUCCESS;
+}
+
+irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) {
+ char info[256];
+ memset(info, '\0', 256);
+
+ if (client == NULL || client->handle == NULL) {
+ return IRECV_E_NO_DEVICE;
+ }
+
+ libusb_get_string_descriptor_ascii(client->handle, 3, info, 255);
+ printf("%d: %s\n", strlen(info), info);
+
+ unsigned char* bdid_string = strstr(info, "BDID:");
+ if (bdid_string == NULL) {
+ *bdid = 0;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+ sscanf(bdid_string, "BDID:%d", bdid);
+
+ return IRECV_E_SUCCESS;
+}
+
irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) {
char info[256];
memset(info, '\0', 256);
@@ -411,7 +453,6 @@ irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) {
}
sscanf(ecid_string, "ECID:%qX", ecid);
- irecv_reset(client);
return IRECV_E_SUCCESS;
}