mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Add callback function to show upload percentage to C example
This commit is contained in:
@@ -34,6 +34,19 @@ static uint8_t *read_file(const char *path, size_t *len) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback function to show progress
|
||||||
|
void progress_callback(size_t progress, size_t total, void *context) {
|
||||||
|
size_t percent = (progress * 100) / total;
|
||||||
|
|
||||||
|
printf("\rUpload progress: %zu%%", percent);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
// Print newline when complete
|
||||||
|
if (progress == total) {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -166,12 +179,12 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount personalized image
|
// Mount personalized image with progress callback
|
||||||
err = image_mounter_mount_personalized_tcp(
|
err = image_mounter_mount_personalized_tcp_with_callback(
|
||||||
mounter_client, provider, image, image_len, trustcache, trustcache_len,
|
mounter_client, provider, image, image_len, trustcache, trustcache_len,
|
||||||
build_manifest, manifest_len,
|
build_manifest, manifest_len,
|
||||||
NULL, // info_plist
|
NULL, // info_plist
|
||||||
unique_chip_id);
|
unique_chip_id, progress_callback, NULL);
|
||||||
|
|
||||||
if (err != IdeviceSuccess) {
|
if (err != IdeviceSuccess) {
|
||||||
fprintf(stderr, "Failed to mount personalized image: %d\n", err);
|
fprintf(stderr, "Failed to mount personalized image: %d\n", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user