diff options
| author | 2011-03-09 20:14:12 +0100 | |
|---|---|---|
| committer | 2011-03-09 20:14:12 +0100 | |
| commit | ee84c231a361ccb85f9eebc40a4c2e1551bcf010 (patch) | |
| tree | e1706dd7100b2ce827e1f7802f697f5af2799682 /libirecovery.c | |
| parent | 95fb4802fe4d76d3ed76a77197ec48ad51f28deb (diff) | |
| download | libirecovery-ee84c231a361ccb85f9eebc40a4c2e1551bcf010.tar.gz libirecovery-ee84c231a361ccb85f9eebc40a4c2e1551bcf010.tar.bz2 | |
Added irecv_get_srnm (serial number) and irecv_get_imei (imei) to libirecovery and /deviceinfo to the irecovery shell which displays basic device information.
Diffstat (limited to 'libirecovery.c')
| -rw-r--r-- | libirecovery.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/libirecovery.c b/libirecovery.c index 84c7b6f..540e01c 100644 --- a/libirecovery.c +++ b/libirecovery.c | |||
| @@ -844,7 +844,7 @@ irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) { | |||
| 844 | 844 | ||
| 845 | irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) { | 845 | irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) { |
| 846 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | 846 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; |
| 847 | 847 | ||
| 848 | char* bdid_string = strstr(client->serial, "BDID:"); | 848 | char* bdid_string = strstr(client->serial, "BDID:"); |
| 849 | if (bdid_string == NULL) { | 849 | if (bdid_string == NULL) { |
| 850 | *bdid = 0; | 850 | *bdid = 0; |
| @@ -868,6 +868,45 @@ irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) { | |||
| 868 | return IRECV_E_SUCCESS; | 868 | return IRECV_E_SUCCESS; |
| 869 | } | 869 | } |
| 870 | 870 | ||
| 871 | irecv_error_t irecv_get_srnm(irecv_client_t client, unsigned char* srnm) { | ||
| 872 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | ||
| 873 | |||
| 874 | char* srnmp; | ||
| 875 | char* srnm_string = strstr(client->serial, "SRNM:["); | ||
| 876 | if(srnm_string == NULL) { | ||
| 877 | srnm = NULL; | ||
| 878 | return IRECV_E_UNKNOWN_ERROR; | ||
| 879 | } | ||
| 880 | |||
| 881 | sscanf(srnm_string, "SRNM:[%s]", srnm); | ||
| 882 | srnmp = strrchr(srnm, ']'); | ||
| 883 | if(srnmp != NULL) { | ||
| 884 | *srnmp = '\0'; | ||
| 885 | } | ||
| 886 | |||
| 887 | return IRECV_E_SUCCESS; | ||
| 888 | } | ||
| 889 | |||
| 890 | irecv_error_t irecv_get_imei(irecv_client_t client, unsigned char* imei) { | ||
| 891 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | ||
| 892 | |||
| 893 | char* imeip; | ||
| 894 | char* imei_string = strstr(client->serial, "IMEI:["); | ||
| 895 | if (imei_string == NULL) { | ||
| 896 | *imei = 0; | ||
| 897 | return IRECV_E_UNKNOWN_ERROR; | ||
| 898 | } | ||
| 899 | |||
| 900 | |||
| 901 | sscanf(imei_string, "IMEI:[%s]", imei); | ||
| 902 | imeip = strrchr(imei, ']'); | ||
| 903 | if(imeip != NULL) { | ||
| 904 | *imeip = '\0'; | ||
| 905 | } | ||
| 906 | |||
| 907 | return IRECV_E_SUCCESS; | ||
| 908 | } | ||
| 909 | |||
| 871 | irecv_error_t irecv_send_exploit(irecv_client_t client) { | 910 | irecv_error_t irecv_send_exploit(irecv_client_t client) { |
| 872 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | 911 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; |
| 873 | irecv_control_transfer(client, 0x21, 2, 0, 0, NULL, 0, 1000); | 912 | irecv_control_transfer(client, 0x21, 2, 0, 0, NULL, 0, 1000); |
| @@ -877,7 +916,7 @@ irecv_error_t irecv_send_exploit(irecv_client_t client) { | |||
| 877 | irecv_error_t irecv_execute_script(irecv_client_t client, const char* filename) { | 916 | irecv_error_t irecv_execute_script(irecv_client_t client, const char* filename) { |
| 878 | irecv_error_t error = IRECV_E_SUCCESS; | 917 | irecv_error_t error = IRECV_E_SUCCESS; |
| 879 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | 918 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; |
| 880 | 919 | ||
| 881 | char* file_data = NULL; | 920 | char* file_data = NULL; |
| 882 | unsigned int file_size = 0; | 921 | unsigned int file_size = 0; |
| 883 | if(irecv_read_file(filename, &file_data, &file_size) < 0) { | 922 | if(irecv_read_file(filename, &file_data, &file_size) < 0) { |
