diff options
Diffstat (limited to 'utils/MTP/sendfirm_win.c')
-rw-r--r-- | utils/MTP/sendfirm_win.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/utils/MTP/sendfirm_win.c b/utils/MTP/sendfirm_win.c index e605d47d0c..c16a7ab68b 100644 --- a/utils/MTP/sendfirm_win.c +++ b/utils/MTP/sendfirm_win.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <wchar.h> | 28 | #include <wchar.h> |
29 | #include <stdbool.h> | 29 | #include <stdbool.h> |
30 | 30 | ||
31 | extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize); | 31 | extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize, void (*callback)(unsigned int progress, unsigned int max)); |
32 | 32 | ||
33 | void usage(void) | 33 | void usage(void) |
34 | { | 34 | { |
@@ -37,9 +37,9 @@ void usage(void) | |||
37 | 37 | ||
38 | int filesize(char* filename) | 38 | int filesize(char* filename) |
39 | { | 39 | { |
40 | FILE* fd; | 40 | FILE* fd; |
41 | int tmp; | 41 | int tmp; |
42 | fd = fopen(filename, "r"); | 42 | fd = fopen(filename, "r"); |
43 | if(fd == NULL) | 43 | if(fd == NULL) |
44 | { | 44 | { |
45 | fprintf(stderr, "Error while opening %s!\n", filename); | 45 | fprintf(stderr, "Error while opening %s!\n", filename); |
@@ -47,10 +47,17 @@ int filesize(char* filename) | |||
47 | } | 47 | } |
48 | fseek(fd, 0, SEEK_END); | 48 | fseek(fd, 0, SEEK_END); |
49 | tmp = ftell(fd); | 49 | tmp = ftell(fd); |
50 | fclose(fd); | 50 | fclose(fd); |
51 | return tmp; | 51 | return tmp; |
52 | } | 52 | } |
53 | 53 | ||
54 | void callback(unsigned int progress, unsigned int max) | ||
55 | { | ||
56 | unsigned int normalized = progress*1000/max; | ||
57 | printf("Progress: %d.%d%%\r", normalized/10, normalized%10); | ||
58 | fflush(stdout); | ||
59 | } | ||
60 | |||
54 | int main(int argc, char **argv) | 61 | int main(int argc, char **argv) |
55 | { | 62 | { |
56 | if (argc < 2) | 63 | if (argc < 2) |
@@ -69,7 +76,7 @@ int main(int argc, char **argv) | |||
69 | 76 | ||
70 | fprintf(stdout, "Sending firmware...\n"); | 77 | fprintf(stdout, "Sending firmware...\n"); |
71 | 78 | ||
72 | if(send_fw(tmp, filesize(argv[1]))) | 79 | if(send_fw(tmp, filesize(argv[1]), &callback)) |
73 | fprintf(stdout, "Firmware sent successfully!\n"); | 80 | fprintf(stdout, "Firmware sent successfully!\n"); |
74 | else | 81 | else |
75 | fprintf(stdout, "Error occured during sending!\n"); | 82 | fprintf(stdout, "Error occured during sending!\n"); |