diff options
Diffstat (limited to 'src/ideviceinstaller.c')
| -rw-r--r-- | src/ideviceinstaller.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index 8b40bb3..28b98ec 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c | |||
| @@ -958,6 +958,52 @@ run_again: | |||
| 958 | printf("Uploading %s package contents... ", basename(appid)); | 958 | printf("Uploading %s package contents... ", basename(appid)); |
| 959 | afc_upload_dir(afc, appid, pkgname); | 959 | afc_upload_dir(afc, appid, pkgname); |
| 960 | printf("DONE.\n"); | 960 | printf("DONE.\n"); |
| 961 | |||
| 962 | /* extract the CFBundleIdentifier from the package */ | ||
| 963 | |||
| 964 | /* construct full filename to Info.plist */ | ||
| 965 | char *filename = (char*)malloc(strlen(appid)+10+1); | ||
| 966 | strcpy(filename, appid); | ||
| 967 | strcat(filename, "/Info.plist"); | ||
| 968 | |||
| 969 | struct stat st; | ||
| 970 | FILE *fp = NULL; | ||
| 971 | |||
| 972 | if (stat(filename, &st) == -1 || (fp = fopen(filename, "r")) == NULL) { | ||
| 973 | fprintf(stderr, "ERROR: could not locate %s in app!\n", filename); | ||
| 974 | free(filename); | ||
| 975 | goto leave_cleanup; | ||
| 976 | } | ||
| 977 | size_t filesize = st.st_size; | ||
| 978 | char *ibuf = malloc(filesize * sizeof(char)); | ||
| 979 | size_t amount = fread(ibuf, 1, filesize, fp); | ||
| 980 | if (amount != filesize) { | ||
| 981 | fprintf(stderr, "ERROR: could not read %ld bytes from %s\n", filesize, filename); | ||
| 982 | free(filename); | ||
| 983 | goto leave_cleanup; | ||
| 984 | } | ||
| 985 | fclose(fp); | ||
| 986 | free(filename); | ||
| 987 | |||
| 988 | plist_t info = NULL; | ||
| 989 | if (memcmp(ibuf, "bplist00", 8) == 0) { | ||
| 990 | plist_from_bin(ibuf, filesize, &info); | ||
| 991 | } else { | ||
| 992 | plist_from_xml(ibuf, filesize, &info); | ||
| 993 | } | ||
| 994 | free(ibuf); | ||
| 995 | |||
| 996 | if (!info) { | ||
| 997 | fprintf(stderr, "ERROR: could not parse Info.plist!\n"); | ||
| 998 | goto leave_cleanup; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | plist_t bname = plist_dict_get_item(info, "CFBundleIdentifier"); | ||
| 1002 | if (bname) { | ||
| 1003 | plist_get_string_val(bname, &bundleidentifier); | ||
| 1004 | } | ||
| 1005 | plist_free(info); | ||
| 1006 | info = NULL; | ||
| 961 | } else { | 1007 | } else { |
| 962 | zf = zip_open(appid, 0, &errp); | 1008 | zf = zip_open(appid, 0, &errp); |
| 963 | if (!zf) { | 1009 | if (!zf) { |
