diff options
Diffstat (limited to 'utils/MTP/sendfirm_win.c')
-rw-r--r-- | utils/MTP/sendfirm_win.c | 174 |
1 files changed, 87 insertions, 87 deletions
diff --git a/utils/MTP/sendfirm_win.c b/utils/MTP/sendfirm_win.c index 3c45aa6ae7..c74b93bb37 100644 --- a/utils/MTP/sendfirm_win.c +++ b/utils/MTP/sendfirm_win.c | |||
@@ -1,87 +1,87 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 Maurus Cuelenaere | 10 | * Copyright (C) 2008 Maurus Cuelenaere |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | #include <stddef.h> | 25 | #include <stddef.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <wchar.h> | 27 | #include <wchar.h> |
28 | #include <stdbool.h> | 28 | #include <stdbool.h> |
29 | #include <windows.h> | 29 | #include <windows.h> |
30 | 30 | ||
31 | #include "MTP_DLL/MTP_DLL.h" | 31 | #include "MTP_DLL/MTP_DLL.h" |
32 | 32 | ||
33 | void usage(void) | 33 | void usage(void) |
34 | { | 34 | { |
35 | fprintf(stderr, "usage: sendfirm <local filename>\n"); | 35 | fprintf(stderr, "usage: sendfirm <local filename>\n"); |
36 | } | 36 | } |
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); |
46 | return -1; | 46 | return -1; |
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) | 54 | void callback(unsigned int progress, unsigned int max) |
55 | { | 55 | { |
56 | unsigned int normalized = progress*1000/max; | 56 | unsigned int normalized = progress*1000/max; |
57 | printf("Progress: %d.%d%%\r", normalized/10, normalized%10); | 57 | printf("Progress: %d.%d%%\r", normalized/10, normalized%10); |
58 | fflush(stdout); | 58 | fflush(stdout); |
59 | } | 59 | } |
60 | 60 | ||
61 | int main(int argc, char **argv) | 61 | int main(int argc, char **argv) |
62 | { | 62 | { |
63 | if (argc < 2) | 63 | if (argc < 2) |
64 | { | 64 | { |
65 | usage(); | 65 | usage(); |
66 | return 1; | 66 | return 1; |
67 | } | 67 | } |
68 | 68 | ||
69 | wchar_t *tmp; | 69 | wchar_t *tmp; |
70 | 70 | ||
71 | tmp = (LPWSTR)malloc(strlen(argv[1])*2+1); | 71 | tmp = (LPWSTR)malloc(strlen(argv[1])*2+1); |
72 | mbstowcs(tmp, argv[1], strlen(argv[1])*2+1); | 72 | mbstowcs(tmp, argv[1], strlen(argv[1])*2+1); |
73 | 73 | ||
74 | wprintf(tmp); | 74 | wprintf(tmp); |
75 | printf("\n"); | 75 | printf("\n"); |
76 | 76 | ||
77 | fprintf(stdout, "Sending firmware...\n"); | 77 | fprintf(stdout, "Sending firmware...\n"); |
78 | 78 | ||
79 | if(mtp_sendnk(tmp, filesize(argv[1]), &callback)) | 79 | if(mtp_sendnk(tmp, filesize(argv[1]), &callback)) |
80 | fprintf(stdout, "Firmware sent successfully!\n"); | 80 | fprintf(stdout, "Firmware sent successfully!\n"); |
81 | else | 81 | else |
82 | fprintf(stdout, "Error occured during sending!\n"); | 82 | fprintf(stdout, "Error occured during sending!\n"); |
83 | 83 | ||
84 | free(tmp); | 84 | free(tmp); |
85 | 85 | ||
86 | exit(0); | 86 | exit(0); |
87 | } | 87 | } |