summaryrefslogtreecommitdiffstats
path: root/utils/MTP/beastpatcher/mtp_win32.c
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-06-08 18:04:10 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-06-08 18:04:10 +0000
commiteebde2a3676f7dd11011fabd7c4d74f0cb6532d5 (patch)
treec8568e4f398f5a1e2fcfc1c937dbbbc18d0f1aeb /utils/MTP/beastpatcher/mtp_win32.c
parent5575f425d64b555ad2399ef6e4ae3d1efcb6627d (diff)
downloadrockbox-eebde2a3676f7dd11011fabd7c4d74f0cb6532d5.tar.gz
rockbox-eebde2a3676f7dd11011fabd7c4d74f0cb6532d5.tar.bz2
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.c27
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 @@
#include <stddef.h>
#include <stdlib.h>
#include <wchar.h>
-#include <stdbool.h>
#include <windows.h>
#include <tchar.h>
#include "mtp_common.h"
-
-extern __declspec(dllimport) bool send_fw(LPWSTR file, int filesize,
- void (*callback)(unsigned int progress, unsigned int max));
+#include "../MTP_DLL/MTP_DLL.h"
int mtp_init(struct mtp_info_t* mtp_info)
{
@@ -71,11 +68,18 @@ int mtp_finished(struct mtp_info_t* mtp_info)
int mtp_scan(struct mtp_info_t* mtp_info)
{
- strcpy(mtp_info->manufacturer,"<unknown>");
- strcpy(mtp_info->modelname,"<unknown>");
- strcpy(mtp_info->version,"<unknown>");
+ wchar_t name[256];
+ wchar_t manufacturer[256];
+ DWORD version;
+ int num = 0;
- return 0;
+ num = mtp_description(name, manufacturer, &version);
+
+ wcstombs(mtp_info->manufacturer, manufacturer, 200);
+ wcstombs(mtp_info->modelname, name, 200);
+
+ sprintf(mtp_info->version, "%x", (unsigned int)version);
+ return (num > 0) ? num : -1;
}
@@ -147,11 +151,11 @@ int mtp_send_firmware(struct mtp_info_t* mtp_info, unsigned char* fwbuf,
return -1;
}
- tmp = (LPWSTR)malloc(strlen(szTempName)*2+1);
- mbstowcs(tmp, szTempName, strlen(szTempName)*2+1);
+ tmp = (LPWSTR)malloc(_tcslen(szTempName)*2+1);
+ mbstowcs(tmp, (char*)szTempName, _tcslen(szTempName)*2+1);
fprintf(stderr, "[INFO] Sending firmware...\n");
- if (send_fw(tmp, fwsize, &callback))
+ if (mtp_sendnk(tmp, fwsize, &callback))
{
fprintf(stderr, "[INFO] Firmware sent successfully\n");
ret = 0;
@@ -172,3 +176,4 @@ int mtp_send_firmware(struct mtp_info_t* mtp_info, unsigned char* fwbuf,
return ret;
}
+