diff options
| author | 2010-06-02 22:12:59 -0400 | |
|---|---|---|
| committer | 2010-06-02 22:12:59 -0400 | |
| commit | ac4f614856a5751336fdb1b29b33060bd6c2eaf1 (patch) | |
| tree | 097a3063556de5a73d16298868a4dd16ecccd4cf | |
| 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
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | include/libirecovery.h | 4 | ||||
| -rw-r--r-- | src/libirecovery.c | 43 |
3 files changed, 46 insertions, 2 deletions
| @@ -23,6 +23,7 @@ install: | |||
| 23 | cp libirecovery.so /usr/local/lib/libirecovery.so | 23 | cp libirecovery.so /usr/local/lib/libirecovery.so |
| 24 | cp include/libirecovery.h /usr/local/include/libirecovery.h | 24 | cp include/libirecovery.h /usr/local/include/libirecovery.h |
| 25 | cp irecovery /usr/local/bin/irecovery | 25 | cp irecovery /usr/local/bin/irecovery |
| 26 | ldconfig | ||
| 26 | 27 | ||
| 27 | uninstall: | 28 | uninstall: |
| 28 | rm -rf /usr/local/lib/libirecovery.so | 29 | rm -rf /usr/local/lib/libirecovery.so |
diff --git a/include/libirecovery.h b/include/libirecovery.h index a501c0f..20ecfc7 100644 --- a/include/libirecovery.h +++ b/include/libirecovery.h | |||
| @@ -83,7 +83,9 @@ irecv_error_t irecv_receive(irecv_client_t client); | |||
| 83 | irecv_error_t irecv_send_exploit(irecv_client_t client); | 83 | irecv_error_t irecv_send_exploit(irecv_client_t client); |
| 84 | irecv_error_t irecv_set_debug(irecv_client_t client, int level); | 84 | irecv_error_t irecv_set_debug(irecv_client_t client, int level); |
| 85 | irecv_error_t irecv_getenv(irecv_client_t client, unsigned char** var); | 85 | irecv_error_t irecv_getenv(irecv_client_t client, unsigned char** var); |
| 86 | irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* pecid); | 86 | irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid); |
| 87 | irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid); | ||
| 88 | irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid); | ||
| 87 | irecv_error_t irecv_send(irecv_client_t client, unsigned char* command); | 89 | irecv_error_t irecv_send(irecv_client_t client, unsigned char* command); |
| 88 | irecv_error_t irecv_send_file(irecv_client_t client, const char* filename); | 90 | irecv_error_t irecv_send_file(irecv_client_t client, const char* filename); |
| 89 | irecv_error_t irecv_send_command(irecv_client_t client, unsigned char* command); | 91 | irecv_error_t irecv_send_command(irecv_client_t client, unsigned char* command); |
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 | ||
