diff options
| author | 2010-06-02 22:12:59 -0400 | |
|---|---|---|
| committer | 2010-06-02 22:12:59 -0400 | |
| commit | ac4f614856a5751336fdb1b29b33060bd6c2eaf1 (patch) | |
| tree | 097a3063556de5a73d16298868a4dd16ecccd4cf /src | |
| parent | 30fd56859f50dea5712492807a1b9784da9fec11 (diff) | |
| download | libirecovery-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')
| -rw-r--r-- | src/libirecovery.c | 43 |
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) { | |||
| 393 | return IRECV_E_SUCCESS; | 393 | return IRECV_E_SUCCESS; |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) { | ||
| 397 | char info[256]; | ||
| 398 | memset(info, '\0', 256); | ||
| 399 | |||
| 400 | if (client == NULL || client->handle == NULL) { | ||
| 401 | return IRECV_E_NO_DEVICE; | ||
| 402 | } | ||
| 403 | |||
| 404 | libusb_get_string_descriptor_ascii(client->handle, 3, info, 255); | ||
| 405 | printf("%d: %s\n", strlen(info), info); | ||
| 406 | |||
| 407 | unsigned char* cpid_string = strstr(info, "CPID:"); | ||
| 408 | if (cpid_string == NULL) { | ||
| 409 | *cpid = 0; | ||
| 410 | return IRECV_E_UNKNOWN_ERROR; | ||
| 411 | } | ||
| 412 | sscanf(cpid_string, "CPID:%d", cpid); | ||
| 413 | |||
| 414 | return IRECV_E_SUCCESS; | ||
| 415 | } | ||
| 416 | |||
| 417 | irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) { | ||
| 418 | char info[256]; | ||
| 419 | memset(info, '\0', 256); | ||
| 420 | |||
| 421 | if (client == NULL || client->handle == NULL) { | ||
| 422 | return IRECV_E_NO_DEVICE; | ||
| 423 | } | ||
| 424 | |||
| 425 | libusb_get_string_descriptor_ascii(client->handle, 3, info, 255); | ||
| 426 | printf("%d: %s\n", strlen(info), info); | ||
| 427 | |||
| 428 | unsigned char* bdid_string = strstr(info, "BDID:"); | ||
| 429 | if (bdid_string == NULL) { | ||
| 430 | *bdid = 0; | ||
| 431 | return IRECV_E_UNKNOWN_ERROR; | ||
| 432 | } | ||
| 433 | sscanf(bdid_string, "BDID:%d", bdid); | ||
| 434 | |||
| 435 | return IRECV_E_SUCCESS; | ||
| 436 | } | ||
| 437 | |||
| 396 | irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) { | 438 | irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) { |
| 397 | char info[256]; | 439 | char info[256]; |
| 398 | memset(info, '\0', 256); | 440 | memset(info, '\0', 256); |
| @@ -411,7 +453,6 @@ irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) { | |||
| 411 | } | 453 | } |
| 412 | sscanf(ecid_string, "ECID:%qX", ecid); | 454 | sscanf(ecid_string, "ECID:%qX", ecid); |
| 413 | 455 | ||
| 414 | irecv_reset(client); | ||
| 415 | return IRECV_E_SUCCESS; | 456 | return IRECV_E_SUCCESS; |
| 416 | } | 457 | } |
| 417 | 458 | ||
