summaryrefslogtreecommitdiff
path: root/utils/MTP/sendfirm_win.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-27 23:07:08 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-27 23:07:08 +0000
commit79177edfb2bb5e934c1630d723a0032c995942d7 (patch)
tree608f77faf1b21a5cddb1d6eb4b8b6d2f1a061262 /utils/MTP/sendfirm_win.c
parente320446f0e74fcc6c5a216e20d3cd499a70658b3 (diff)
MTP:
* Add Win32 progress callback reporting support git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18355 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/MTP/sendfirm_win.c')
-rw-r--r--utils/MTP/sendfirm_win.c17
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 @@
#include <wchar.h>
#include <stdbool.h>
-extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize);
+extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize, void (*callback)(unsigned int progress, unsigned int max));
void usage(void)
{
@@ -37,9 +37,9 @@ void usage(void)
int filesize(char* filename)
{
- FILE* fd;
+ FILE* fd;
int tmp;
- fd = fopen(filename, "r");
+ fd = fopen(filename, "r");
if(fd == NULL)
{
fprintf(stderr, "Error while opening %s!\n", filename);
@@ -47,10 +47,17 @@ int filesize(char* filename)
}
fseek(fd, 0, SEEK_END);
tmp = ftell(fd);
- fclose(fd);
+ fclose(fd);
return tmp;
}
+void callback(unsigned int progress, unsigned int max)
+{
+ unsigned int normalized = progress*1000/max;
+ printf("Progress: %d.%d%%\r", normalized/10, normalized%10);
+ fflush(stdout);
+}
+
int main(int argc, char **argv)
{
if (argc < 2)
@@ -69,7 +76,7 @@ int main(int argc, char **argv)
fprintf(stdout, "Sending firmware...\n");
- if(send_fw(tmp, filesize(argv[1])))
+ if(send_fw(tmp, filesize(argv[1]), &callback))
fprintf(stdout, "Firmware sent successfully!\n");
else
fprintf(stdout, "Error occured during sending!\n");