1
0
Fork 0
forked from len0rd/rockbox
* Add Win32 progress callback reporting support


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18355 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2008-08-27 23:07:08 +00:00
parent e320446f0e
commit 79177edfb2
6 changed files with 178 additions and 95 deletions

View file

@ -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");