diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-06-08 18:04:10 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-06-08 18:04:10 +0000 |
commit | eebde2a3676f7dd11011fabd7c4d74f0cb6532d5 (patch) | |
tree | c8568e4f398f5a1e2fcfc1c937dbbbc18d0f1aeb /utils/MTP/beastpatcher/mtp_win32.c | |
parent | 5575f425d64b555ad2399ef6e4ae3d1efcb6627d (diff) | |
download | rockbox-eebde2a3676f7dd11011fabd7c4d74f0cb6532d5.tar.gz rockbox-eebde2a3676f7dd11011fabd7c4d74f0cb6532d5.zip |
Major W32 beastpatcher rework (FS#10220).
Update beastpatcher to scan for the device separately, rework MTP_DLL and modify to allow building with VS2005.
- include pstdint.h when building with VS2005 as VS doesn't have inttypes.h
- don't use bool in the DLL as VS doesn't support type bool in C.
- rearrange DLL files to avoid filename ambiguities with sendfirm.
- include MTP_DLL.h instead of duplicating prototypes. Adjust header for easy inclusion.
- make MTP_DLL project file also copy the resulting dll to MTP folder for convenience.
- extend MTP_DLL API for separate device scanning. Note that this (intentionally) breaks compatibility of the dll.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21221 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/MTP/beastpatcher/mtp_win32.c')
-rw-r--r-- | utils/MTP/beastpatcher/mtp_win32.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/utils/MTP/beastpatcher/mtp_win32.c b/utils/MTP/beastpatcher/mtp_win32.c index f68faddbc2..ced930ab80 100644 --- a/utils/MTP/beastpatcher/mtp_win32.c +++ b/utils/MTP/beastpatcher/mtp_win32.c | |||
@@ -43,15 +43,12 @@ | |||
43 | #include <stddef.h> | 43 | #include <stddef.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <wchar.h> | 45 | #include <wchar.h> |
46 | #include <stdbool.h> | ||
47 | #include <windows.h> | 46 | #include <windows.h> |
48 | #include <tchar.h> | 47 | #include <tchar.h> |
49 | 48 | ||
50 | #include "mtp_common.h" | 49 | #include "mtp_common.h" |
51 | 50 | ||
52 | 51 | #include "../MTP_DLL/MTP_DLL.h" | |
53 | extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize, | ||
54 | void (*callback)(unsigned int progress, unsigned int max)); | ||
55 | 52 | ||
56 | int mtp_init(struct mtp_info_t* mtp_info) | 53 | int mtp_init(struct mtp_info_t* mtp_info) |
57 | { | 54 | { |
@@ -71,11 +68,18 @@ int mtp_finished(struct mtp_info_t* mtp_info) | |||
71 | 68 | ||
72 | int mtp_scan(struct mtp_info_t* mtp_info) | 69 | int mtp_scan(struct mtp_info_t* mtp_info) |
73 | { | 70 | { |
74 | strcpy(mtp_info->manufacturer,"<unknown>"); | 71 | wchar_t name[256]; |
75 | strcpy(mtp_info->modelname,"<unknown>"); | 72 | wchar_t manufacturer[256]; |
76 | strcpy(mtp_info->version,"<unknown>"); | 73 | DWORD version; |
74 | int num = 0; | ||
77 | 75 | ||
78 | return 0; | 76 | num = mtp_description(name, manufacturer, &version); |
77 | |||
78 | wcstombs(mtp_info->manufacturer, manufacturer, 200); | ||
79 | wcstombs(mtp_info->modelname, name, 200); | ||
80 | |||
81 | sprintf(mtp_info->version, "%x", (unsigned int)version); | ||
82 | return (num > 0) ? num : -1; | ||
79 | 83 | ||
80 | } | 84 | } |
81 | 85 | ||
@@ -147,11 +151,11 @@ int mtp_send_firmware(struct mtp_info_t* mtp_info, unsigned char* fwbuf, | |||
147 | return -1; | 151 | return -1; |
148 | } | 152 | } |
149 | 153 | ||
150 | tmp = (LPWSTR)malloc(strlen(szTempName)*2+1); | 154 | tmp = (LPWSTR)malloc(_tcslen(szTempName)*2+1); |
151 | mbstowcs(tmp, szTempName, strlen(szTempName)*2+1); | 155 | mbstowcs(tmp, (char*)szTempName, _tcslen(szTempName)*2+1); |
152 | 156 | ||
153 | fprintf(stderr, "[INFO] Sending firmware...\n"); | 157 | fprintf(stderr, "[INFO] Sending firmware...\n"); |
154 | if (send_fw(tmp, fwsize, &callback)) | 158 | if (mtp_sendnk(tmp, fwsize, &callback)) |
155 | { | 159 | { |
156 | fprintf(stderr, "[INFO] Firmware sent successfully\n"); | 160 | fprintf(stderr, "[INFO] Firmware sent successfully\n"); |
157 | ret = 0; | 161 | ret = 0; |
@@ -172,3 +176,4 @@ int mtp_send_firmware(struct mtp_info_t* mtp_info, unsigned char* fwbuf, | |||
172 | 176 | ||
173 | return ret; | 177 | return ret; |
174 | } | 178 | } |
179 | |||