1
0
Fork 0
forked from len0rd/rockbox

Fix compilation of sendfirm with 0.3.x versions of libmtp and keep a (hacky) fallback for building with the older 0.2.x also fix a pair of 64 bit warnings

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19941 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2009-02-07 21:00:18 +00:00
parent 7ae9c8d5ce
commit ef726cee67
2 changed files with 12 additions and 5 deletions

View file

@ -5,7 +5,7 @@ OUTPUT = sendfirm
all: $(OUTPUT) all: $(OUTPUT)
$(OUTPUT): sendfirm.c $(OUTPUT): sendfirm.c
gcc $(CFLAGS) $(LIBS) -o $(OUTPUT) sendfirm.c gcc $(CFLAGS) $(LIBS) -o $(OUTPUT) sendfirm.c || gcc $(CFLAGS) $(LIBS) -DOLDMTP -o $(OUTPUT) sendfirm.c
$(OUTPUT).exe: sendfirm_win.c $(OUTPUT).exe: sendfirm_win.c
mingw32-gcc $(CFLAGS) -o $(OUTPUT).exe sendfirm_win.c MTP_DLL.dll mingw32-gcc $(CFLAGS) -o $(OUTPUT).exe sendfirm_win.c MTP_DLL.dll

View file

@ -31,18 +31,19 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h>
#include "libmtp.h" #include "libmtp.h"
LIBMTP_mtpdevice_t *device; LIBMTP_mtpdevice_t *device;
static int progress(u_int64_t const sent, u_int64_t const total, static int progress(uint64_t const sent, uint64_t const total,
void const *const data) void const *const data)
{ {
int percent = (sent * 100) / total; int percent = (sent * 100) / total;
#ifdef __WIN32__ #ifdef __WIN32__
printf("Progress: %I64u of %I64u (%d%%)\r", sent, total, percent); printf("Progress: %I64u of %I64u (%d%%)\r", sent, total, percent);
#else #else
printf("Progress: %llu of %llu (%d%%)\r", sent, total, percent); printf("Progress: %"PRIu64" of %"PRIu64" (%d%%)\r", sent, total, percent);
#endif #endif
fflush(stdout); fflush(stdout);
return 0; return 0;
@ -64,7 +65,6 @@ int sendfile_function(char *from_path)
#endif #endif
LIBMTP_file_t *genfile; LIBMTP_file_t *genfile;
int ret; int ret;
uint32_t parent_id = 0;
#ifdef __USE_LARGEFILE64 #ifdef __USE_LARGEFILE64
if (stat64(from_path, &sb) == -1) if (stat64(from_path, &sb) == -1)
@ -90,8 +90,15 @@ int sendfile_function(char *from_path)
genfile->filetype = LIBMTP_FILETYPE_FIRMWARE; genfile->filetype = LIBMTP_FILETYPE_FIRMWARE;
printf("Sending file...\n"); printf("Sending file...\n");
#ifdef OLDMTP
ret = LIBMTP_Send_File_From_File(device, from_path, genfile, progress, ret = LIBMTP_Send_File_From_File(device, from_path, genfile, progress,
NULL, parent_id); NULL, 0);
#else
ret = LIBMTP_Send_File_From_File(device, from_path, genfile, progress,
NULL);
#endif
printf("\n"); printf("\n");
if (ret != 0) if (ret != 0)
{ {