summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-07-16 18:46:37 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-07-16 18:46:37 +0000
commit08a27c1df7e269766ca0f583047884fa127eb5ec (patch)
treeb02cd34dbc8afd7f1ffcaa3068a6ffc31b254dfb /rbutil
parentc025bfc086a5d30e71f269c182d3de6f127340c3 (diff)
downloadrockbox-08a27c1df7e269766ca0f583047884fa127eb5ec.tar.gz
rockbox-08a27c1df7e269766ca0f583047884fa127eb5ec.tar.bz2
rockbox-08a27c1df7e269766ca0f583047884fa127eb5ec.zip
Let sansa_list_images() return the number of mi4 images found.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18074 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/sansapatcher/sansapatcher.c12
-rw-r--r--rbutil/sansapatcher/sansapatcher.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index 966cfb7033..845333bd76 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -800,28 +800,34 @@ int sansa_delete_bootloader(struct sansa_t* sansa)
return 0;
}
-void sansa_list_images(struct sansa_t* sansa)
+/** List number of MI4 images on the player, return number.
+ */
+int sansa_list_images(struct sansa_t* sansa)
{
struct mi4header_t mi4header;
loff_t ppmi_length;
+ int num = 0;
/* Check Main firmware header */
if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET, sansa_sectorbuf, 0x200) < 0) {
- return;
+ return 0;
}
ppmi_length = le2int(sansa_sectorbuf+4);
printf("[INFO] Image 1 - %llu bytes\n",ppmi_length);
+ num = 1;
/* Look for an original firmware after the first image */
if (sansa_seek_and_read(sansa, sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, sansa_sectorbuf, 512) < 0) {
- return;
+ return 0;
}
if (get_mi4header(sansa_sectorbuf,&mi4header)==0) {
printf("[INFO] Image 2 - %d bytes\n",mi4header.mi4size);
+ num = 2;
}
+ return num;
}
int sansa_update_of(struct sansa_t* sansa, const char* filename)
diff --git a/rbutil/sansapatcher/sansapatcher.h b/rbutil/sansapatcher/sansapatcher.h
index 170646b1d8..7416e1928b 100644
--- a/rbutil/sansapatcher/sansapatcher.h
+++ b/rbutil/sansapatcher/sansapatcher.h
@@ -45,7 +45,7 @@ int sansa_add_bootloader(struct sansa_t* sansa, const char* filename, int type);
int sansa_delete_bootloader(struct sansa_t* sansa);
int sansa_update_of(struct sansa_t* sansa,const char* filename);
int sansa_update_ppbl(struct sansa_t* sansa,const char* filename);
-void sansa_list_images(struct sansa_t* sansa);
+int sansa_list_images(struct sansa_t* sansa);
#ifdef __cplusplus
}