|
From: <ny...@us...> - 2007-09-12 14:25:34
|
Revision: 409
http://pmplib.svn.sourceforge.net/pmplib/?rev=409&view=rev
Author: nyaochi
Date: 2007-09-12 07:25:36 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
- Added "itunes_" prefix to structure names
- Initial attempt to support iTunes 7.4.1;
database dump appears to work
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/itunesdb.c
trunk/pmplib/lib/pmp_ipod/itunesdb.h
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 14:25:36 UTC (rev 409)
@@ -290,7 +290,7 @@
{
int ret = 0;
itunesdb_chunk_t* mhod = NULL;
- chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
+ itunesdb_mhit_t* mhit_data = (itunesdb_mhit_t*)mhit->data;
mhit_data->uid = uid;
mhit_data->visible = 1;
@@ -418,7 +418,7 @@
uint32_t i;
int ret = 0;
itunesdb_chunk_t* mhod = NULL;
- chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
+ itunesdb_mhit_t* mhit_data = (itunesdb_mhit_t*)mhit->data;
switch (mhit_data->filetype) {
case 0x4D503320:
@@ -588,7 +588,7 @@
int i;
int ret = 0;
itunesdb_chunk_t *mhod = NULL, *mhip = NULL;
- chunk_mhyp_t* mhyp_data = (chunk_mhyp_t*)mhyp->data;
+ itunesdb_mhyp_t* mhyp_data = (itunesdb_mhyp_t*)mhyp->data;
sorted_index_t* si = (sorted_index_t*)calloc(num_records, sizeof(sorted_index_t));
const static ucs2char_t ucs2cs_master[] = {'M','a','s','t','e','r',0};
@@ -660,9 +660,9 @@
for (i = 0;i < num_records;++i) {
mhip = itunesdb_new_child(mhyp);
if (mhip) {
- chunk_mhip_t* mhip_data = NULL;
+ itunesdb_mhip_t* mhip_data = NULL;
if (ret = itunesdb_init(mhip, "mhip", NULL)) return ret;
- mhip_data = (chunk_mhip_t*)mhip->data;
+ mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = i;
@@ -703,7 +703,7 @@
int i;
int ret = 0;
itunesdb_chunk_t *mhod = NULL, *mhip = NULL;
- chunk_mhyp_t* mhyp_data = (chunk_mhyp_t*)mhyp->data;
+ itunesdb_mhyp_t* mhyp_data = (itunesdb_mhyp_t*)mhyp->data;
mhyp_data->flag_master = 0;
mhyp_data->id = 0x7520EA5FA870F9EA;
@@ -728,9 +728,9 @@
if (index < num_records) {
mhip = itunesdb_new_child(mhyp);
if (mhip) {
- chunk_mhip_t* mhip_data = NULL;
+ itunesdb_mhip_t* mhip_data = NULL;
if (ret = itunesdb_init(mhip, "mhip", NULL)) return ret;
- mhip_data = (chunk_mhip_t*)mhip->data;
+ mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = index;
@@ -769,7 +769,7 @@
itunesdb_chunk_t *mhbd = NULL, *mhsd = NULL;
itunesdb_chunk_t *mhlt = NULL, *mhit = NULL;
itunesdb_chunk_t *mhlp = NULL, *mhyp = NULL;
- chunk_mhbd_t* mhbd_data = NULL;
+ itunesdb_mhbd_t* mhbd_data = NULL;
/* Construct "mhbd" chunk. */
mhbd = (itunesdb_chunk_t*)calloc(1, sizeof(itunesdb_chunk_t));
@@ -777,14 +777,14 @@
return IPODE_FAILEDNEWCHUNK;
}
if (ret = itunesdb_init(mhbd, "mhbd", NULL)) return ret;
- mhbd_data = (chunk_mhbd_t*)mhbd->data;
+ mhbd_data = (itunesdb_mhbd_t*)mhbd->data;
/* Construct "mhsd" chunk with track type. */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
- chunk_mhsd_t* mhsd_data = NULL;
+ itunesdb_mhsd_t* mhsd_data = NULL;
if (ret = itunesdb_init(mhsd, "mhsd", NULL)) return ret;
- mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 1; /* track type. */
/* Construct "mhlt" chunk. */
@@ -817,9 +817,9 @@
/* Construct "mhsd" chunk with playlist type. */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
- chunk_mhsd_t* mhsd_data = NULL;
+ itunesdb_mhsd_t* mhsd_data = NULL;
if (ret = itunesdb_init(mhsd, "mhsd", NULL)) return ret;
- mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 2; /* playlist type. */
/* Construct "mhlp" chunk. */
@@ -830,7 +830,7 @@
/* Create a master playlist. */
mhyp = itunesdb_new_child(mhlp);
if (mhyp) {
- chunk_mhyp_t* mhyp_data = NULL;
+ itunesdb_mhyp_t* mhyp_data = NULL;
if (ret = itunesdb_init(mhyp, "mhyp", NULL)) return ret;
if (ret = set_master_playlist(mhyp, records, num_records)) return ret;
}
@@ -839,7 +839,7 @@
for (i = 0;i < num_playlists;++i) {
mhyp = itunesdb_new_child(mhlp);
if (mhyp) {
- chunk_mhyp_t* mhyp_data = NULL;
+ itunesdb_mhyp_t* mhyp_data = NULL;
if (ret = itunesdb_init(mhyp, "mhyp", NULL)) return ret;
if (ret = set_playlist(mhyp, &playlists[i], records, num_records)) return ret;
} else {
@@ -883,7 +883,7 @@
for (i = 0;i < mhbd->num_children;++i) {
mhsd = &mhbd->childlen[i];
if (mhsd && strncmp(mhsd->id, "mhsd", 4) == 0) {
- chunk_mhsd_t* mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ itunesdb_mhsd_t* mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
if (mhsd_data->type == 1) {
/* Track list. */
for (j = 0;j < mhsd->num_children;++j) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 14:25:36 UTC (rev 409)
@@ -50,7 +50,7 @@
static int mhbd_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhbd_t* mhbd = NULL;
+ itunesdb_mhbd_t* mhbd = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -59,7 +59,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhbd = (chunk_mhbd_t*)calloc(1, sizeof(chunk_mhbd_t));
+ mhbd = (itunesdb_mhbd_t*)calloc(1, sizeof(itunesdb_mhbd_t));
if (def && mhbd) {
mhbd->unknown1 = 1;
mhbd->version = 0x13; /* iTunes 7 */
@@ -78,7 +78,7 @@
static int mhbd_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhbd_t* mhbd = (chunk_mhbd_t*)chunk->data;
+ itunesdb_mhbd_t* mhbd = (itunesdb_mhbd_t*)chunk->data;
if (ret = serialize_uint32le(sio, "unknown1", "%d", &mhbd->unknown1)) return ret;
if (ret = serialize_uint32le(sio, "version", "%d", &mhbd->version)) return ret;
@@ -97,7 +97,7 @@
static mhsd_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhsd_t* mhsd = NULL;
+ itunesdb_mhsd_t* mhsd = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -106,7 +106,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhsd = (chunk_mhsd_t*)calloc(1, sizeof(chunk_mhsd_t));
+ mhsd = (itunesdb_mhsd_t*)calloc(1, sizeof(itunesdb_mhsd_t));
if (mhsd && def) {
mhsd->type = 0; /* to be filled */
}
@@ -118,7 +118,7 @@
static int mhsd_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhsd_t* mhsd = (chunk_mhsd_t*)chunk->data;
+ itunesdb_mhsd_t* mhsd = (itunesdb_mhsd_t*)chunk->data;
if (ret = serialize_uint32le(sio, "type", "%d", &mhsd->type)) return ret;
@@ -127,9 +127,68 @@
+static mhla_init(itunesdb_chunk_t* chunk, int def)
+{
+ itunesdb_mhla_t* mhla = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhla", 4);
+ chunk->size = 92;
+ chunk->overall_size = 0; /* to be filled */
+ }
+ mhla = (itunesdb_mhla_t*)calloc(1, sizeof(itunesdb_mhla_t));
+
+ chunk->data = mhla;
+ return mhla ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhla_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ itunesdb_mhla_t* mhla = (itunesdb_mhla_t*)chunk->data;
+
+ if (ret = serialize_uint8(sio, "unknown", "%02X", &mhla->unknown)) return ret;
+
+ return 0;
+}
+
+
+
+static mhia_init(itunesdb_chunk_t* chunk, int def)
+{
+ itunesdb_mhia_t* mhia = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhia", 4);
+ chunk->size = 88;
+ chunk->overall_size = 0; /* to be filled */
+ }
+ mhia = (itunesdb_mhia_t*)calloc(1, sizeof(itunesdb_mhia_t));
+
+ chunk->data = mhia;
+ return mhia ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhia_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ itunesdb_mhia_t* mhia = (itunesdb_mhia_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "num_children", "%u", &mhia->num_children)) return ret;
+ if (ret = serialize_uint32le(sio, "album_id", "%u", &mhia->album_id)) return ret;
+ if (ret = serialize_uint64le(sio, "timestamp", "%u", &mhia->timestamp)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown1", "%u", &mhia->unknown1)) return ret;
+
+ return 0;
+}
+
+
+
static mhlt_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhlt_t* mhlt = NULL;
+ itunesdb_mhlt_t* mhlt = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -137,7 +196,7 @@
chunk->size = 92;
chunk->overall_size = 0; /* to be filled */
}
- mhlt = (chunk_mhlt_t*)calloc(1, sizeof(chunk_mhlt_t));
+ mhlt = (itunesdb_mhlt_t*)calloc(1, sizeof(itunesdb_mhlt_t));
chunk->data = mhlt;
return mhlt ? 0 : IPODE_OUTOFMEMORY;
@@ -146,7 +205,7 @@
static int mhlt_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhlt_t* mhlt = (chunk_mhlt_t*)chunk->data;
+ itunesdb_mhlt_t* mhlt = (itunesdb_mhlt_t*)chunk->data;
if (ret = serialize_uint8(sio, "unknown", "%02X", &mhlt->unknown)) return ret;
@@ -157,7 +216,7 @@
static mhit_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhit_t* mhit = NULL;
+ itunesdb_mhit_t* mhit = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -166,7 +225,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhit = (chunk_mhit_t*)calloc(1, sizeof(chunk_mhit_t));
+ mhit = (itunesdb_mhit_t*)calloc(1, sizeof(itunesdb_mhit_t));
if (mhit && def) {
mhit->visible = 1; /* visible by default */
/* other fields to be filled later */
@@ -179,7 +238,7 @@
static int mhit_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhit_t* mhit = (chunk_mhit_t*)chunk->data;
+ itunesdb_mhit_t* mhit = (itunesdb_mhit_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_children", "%u", &mhit->num_children)) return ret;
if (ret = serialize_uint32le(sio, "uid", "%u", &mhit->uid)) return ret;
@@ -263,7 +322,7 @@
static mhlp_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhlp_t* mhlp = NULL;
+ itunesdb_mhlp_t* mhlp = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -272,7 +331,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhlp = (chunk_mhlp_t*)calloc(1, sizeof(chunk_mhlp_t));
+ mhlp = (itunesdb_mhlp_t*)calloc(1, sizeof(itunesdb_mhlp_t));
chunk->data = mhlp;
return mhlp ? 0 : IPODE_OUTOFMEMORY;
}
@@ -280,7 +339,7 @@
static int mhlp_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhlp_t* mhlp = (chunk_mhlp_t*)chunk->data;
+ itunesdb_mhlp_t* mhlp = (itunesdb_mhlp_t*)chunk->data;
if (ret = serialize_uint8(sio, "unknown", "%02X", &mhlp->unknown)) return ret;
@@ -291,7 +350,7 @@
static mhyp_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhyp_t* mhyp = NULL;
+ itunesdb_mhyp_t* mhyp = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -300,7 +359,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhyp = (chunk_mhyp_t*)calloc(1, sizeof(chunk_mhyp_t));
+ mhyp = (itunesdb_mhyp_t*)calloc(1, sizeof(itunesdb_mhyp_t));
chunk->data = mhyp;
return mhyp ? 0 : IPODE_OUTOFMEMORY;
}
@@ -308,7 +367,7 @@
static int mhyp_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhyp_t* mhyp = (chunk_mhyp_t*)chunk->data;
+ itunesdb_mhyp_t* mhyp = (itunesdb_mhyp_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_mhod", "%u", &mhyp->num_mhod)) return ret;
if (ret = serialize_uint32le(sio, "num_mhip", "%u", &mhyp->num_mhip)) return ret;
@@ -330,7 +389,7 @@
static mhip_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhip_t* mhip = NULL;
+ itunesdb_mhip_t* mhip = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -339,7 +398,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhip = (chunk_mhip_t*)calloc(1, sizeof(chunk_mhip_t));
+ mhip = (itunesdb_mhip_t*)calloc(1, sizeof(itunesdb_mhip_t));
chunk->data = mhip;
return mhip ? 0 : IPODE_OUTOFMEMORY;
}
@@ -347,7 +406,7 @@
static int mhip_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhip_t* mhip = (chunk_mhip_t*)chunk->data;
+ itunesdb_mhip_t* mhip = (itunesdb_mhip_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_mhod", "%u", &mhip->num_mhod)) return ret;
if (ret = serialize_uint32le(sio, "flag_podcast_group", "%X", &mhip->flag_podcast_group)) return ret;
@@ -363,8 +422,8 @@
static void mhod_string_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* string = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* string = &mhod->data.str;
ucs2free(string->value);
memset(string, 0, sizeof(*string));
}
@@ -372,7 +431,7 @@
static int mhod_string_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_string_t* string = &((chunk_mhod_t*)chunk->data)->data.str;
+ itunesdb_mhod_string_t* string = &((itunesdb_mhod_t*)chunk->data)->data.str;
if (ret = serialize_uint32le(sio, "position", "%u", &string->position)) return ret;
if (ret = serialize_uint32le(sio, "size", "%u", &string->size)) return ret;
@@ -385,8 +444,8 @@
static void mhod_url_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_url_t* url = &mhod->data.url;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_url_t* url = &mhod->data.url;
ucs2free(url->value);
memset(url, 0, sizeof(*url));
}
@@ -394,8 +453,8 @@
static int mhod_url_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_url_t* url = &mhod->data.url;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_url_t* url = &mhod->data.url;
if (ret = serialize_utf8str_fixed(sio, name, "%s", &url->value, chunk->size - chunk->overall_size)) return ret;
@@ -404,8 +463,8 @@
static void mhod_index_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
ucs2free(index->entries);
memset(index, 0, sizeof(*index));
}
@@ -414,8 +473,8 @@
{
uint32_t i;
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
if (ret = serialize_uint32le(sio, "type", "%u", &index->type)) return ret;
if (ret = serialize_uint32le(sio, "num_entries", "%u", &index->num_entries)) return ret;
@@ -438,10 +497,54 @@
return 0;
}
+static void mhod_library_playlist_index_finish(itunesdb_chunk_t* chunk)
+{
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_library_playlist_index_t* lp_index = &mhod->data.lp_index;
+ ucs2free(lp_index->entries);
+ memset(lp_index, 0, sizeof(*lp_index));
+}
+
+static int mhod_library_playlist_index_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
+{
+ uint32_t i;
+ int ret = 0;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_library_playlist_index_t* lp_index = &mhod->data.lp_index;
+
+ if (ret = serialize_uint32le(sio, "type", "%u", &lp_index->type)) return ret;
+ if (ret = serialize_uint32le(sio, "num_entries", "%u", &lp_index->num_entries)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown1", "%u", &lp_index->unknown1)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown2", "%u", &lp_index->unknown2)) return ret;
+
+ /* Allocate array when reading. */
+ if (serialize_reading(sio)) {
+ lp_index->entries = calloc(
+ lp_index->num_entries,
+ sizeof(itunesdb_mhod_library_playlist_entry_t)
+ );
+ if (!lp_index->entries) {
+ return IPODE_OUTOFMEMORY;
+ }
+ }
+
+ for (i = 0;i < lp_index->num_entries;++i) {
+ char fieldname[128];
+ sprintf(fieldname, "entries[%d].unknown1", i);
+ if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown1)) return ret;
+ sprintf(fieldname, "entries[%d].unknown2", i);
+ if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown2)) return ret;
+ sprintf(fieldname, "entries[%d].unknown3", i);
+ if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown3)) return ret;
+ }
+
+ return 0;
+}
+
static void mhod_playlist_column_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_column_t* pc = &mhod->data.pc;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_column_t* pc = &mhod->data.pc;
ucs2free(pc->columns);
memset(pc, 0, sizeof(*pc));
}
@@ -450,8 +553,8 @@
{
uint32_t i;
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_column_t* pc = &mhod->data.pc;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_column_t* pc = &mhod->data.pc;
if (ret = serialize_uint32le(sio, "unk3", "%u", &pc->unk3)) return ret;
if (ret = serialize_uint64le(sio, "unk4", "%016llX", &pc->unk4)) return ret;
@@ -464,8 +567,8 @@
/* Allocate array when reading. */
if (serialize_reading(sio)) {
- pc->columns = (chunk_mhod_playlist_column_definition_t*)calloc(
- pc->num_columns, sizeof(chunk_mhod_playlist_column_definition_t));
+ pc->columns = (itunesdb_mhod_playlist_column_definition_t*)calloc(
+ pc->num_columns, sizeof(itunesdb_mhod_playlist_column_definition_t));
if (!pc->columns) {
return IPODE_OUTOFMEMORY;
}
@@ -473,7 +576,7 @@
for (i = 0;i < pc->num_columns;++i) {
char fieldname[128];
- chunk_mhod_playlist_column_definition_t* def = &pc->columns[i];
+ itunesdb_mhod_playlist_column_definition_t* def = &pc->columns[i];
sprintf(fieldname, "columns[%d].id", i);
if (ret = serialize_uint16le(sio, fieldname, "%u", &def->id)) return ret;
@@ -490,16 +593,16 @@
static void mhod_playlist_order_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
memset(po, 0, sizeof(*po));
}
static int mhod_playlist_order_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
if (ret = serialize_uint32le(sio, "position", "%u", &po->position)) return ret;
if (ret = serialize_uint8_array(sio, "unknown", "%02X ", po->unknown, sizeof(po->unknown))) return ret;
@@ -522,16 +625,24 @@
{14, "description", 0, mhod_string_finish, mhod_string_serialize},
{15, "podcast_enclosure_url", 0, mhod_url_finish, mhod_url_serialize},
{16, "podcast_rss_url", 0, mhod_url_finish, mhod_url_serialize},
+ {27, "sort_title", 0, mhod_string_finish, mhod_string_serialize},
+ {28, "sort_album", 0, mhod_string_finish, mhod_string_serialize},
+ {29, "sort_albumartist", 0, mhod_string_finish, mhod_string_serialize},
+ {30, "sort_composer", 0, mhod_string_finish, mhod_string_serialize},
{52, "index", 0, mhod_index_finish, mhod_index_serialize},
+ {53, "library_playlist_index", 0, mhod_library_playlist_index_finish, mhod_library_playlist_index_serialize},
{100, "playlist_column", 0x288, mhod_playlist_column_finish, mhod_playlist_column_serialize},
{100, "playlist_order", 0x2C, mhod_playlist_order_finish, mhod_playlist_order_serialize},
+ {200, "album_albumlist", 0, mhod_string_finish, mhod_string_serialize},
+ {201, "artist_albumlist", 0, mhod_string_finish, mhod_string_serialize},
+ {202, "sort_artist_albumlist", 0, mhod_string_finish, mhod_string_serialize},
{0, NULL, 0, NULL},
};
static const itunesdb_mhoddecl_t* find_mhoddecl(itunesdb_chunk_t* chunk)
{
const itunesdb_mhoddecl_t* decl = mds;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
while (decl->name) {
if (decl->type == mhod->type) {
@@ -565,13 +676,13 @@
chunk->size = 24;
chunk->overall_size = chunk->size;
}
- chunk->data = calloc(1, sizeof(chunk_mhod_t));
+ chunk->data = calloc(1, sizeof(itunesdb_mhod_t));
return chunk->data ? 0 : IPODE_OUTOFMEMORY;
}
static void mhod_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = NULL;
decl = find_mhoddecl(chunk);
if (decl) {
@@ -583,7 +694,7 @@
static int mhod_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = NULL;
if (ret = serialize_uint32le(sio, "type", "%u", &mhod->type)) return ret;
@@ -609,6 +720,8 @@
static const itunesdb_chunkdecl_t cds[] = {
{"mhbd", mhbd_init, chunk_finish, mhbd_serialize},
{"mhsd", mhsd_init, chunk_finish, mhsd_serialize},
+ {"mhla", mhla_init, chunk_finish, mhla_serialize},
+ {"mhia", mhia_init, chunk_finish, mhia_serialize},
{"mhlt", mhlt_init, chunk_finish, mhlt_serialize},
{"mhit", mhit_init, chunk_finish, mhit_serialize},
{"mhlp", mhlp_init, chunk_finish, mhlp_serialize},
@@ -638,7 +751,7 @@
if (ret = decl->init(chunk, 1)) return ret;
if (strncmp(name, "mhod", 4) == 0) {
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl2 = find_mhoddecl_by_name(subtype);
if (!decl2) {
decl->finish(chunk);
@@ -653,7 +766,7 @@
int itunesdb_ischunk(itunesdb_chunk_t* chunk, const char *name, const char *subtype)
{
if (strncmp(name, "mhod", 4) == 0) {
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = find_mhoddecl(chunk);
return (decl && strcmp(decl->name, subtype) == 0) ? 1 : 0;
} else {
@@ -875,8 +988,8 @@
int itunesdb_set_mhod_string(itunesdb_chunk_t* chunk, const ucs2char_t* value)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* str = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* str = &mhod->data.str;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -896,8 +1009,8 @@
int itunesdb_get_mhod_string(itunesdb_chunk_t* chunk, ucs2char_t** value)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* str = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* str = &mhod->data.str;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -915,8 +1028,8 @@
int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t type, sorted_index_t* si, uint32_t n)
{
uint32_t i;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -938,8 +1051,8 @@
int itunesdb_set_mhod_playlist_order(itunesdb_chunk_t* chunk, uint32_t order)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-12 14:25:36 UTC (rev 409)
@@ -34,15 +34,26 @@
uint64_t unknown4;
uint8_t unknown5[26]; /* zero padded. */
uint8_t language[2]; /* e.g., "en", "ja" */
-} chunk_mhbd_t;
+} itunesdb_mhbd_t;
typedef struct {
uint32_t type; /* 1 (track list), 2 (playlist list), or 3 (podcast list). */
-} chunk_mhsd_t;
+} itunesdb_mhsd_t;
typedef struct {
+ uint8_t unknown; /* Zero padded. */
+} itunesdb_mhla_t;
+
+typedef struct {
+ uint32_t num_children;
+ uint32_t album_id;
+ uint64_t timestamp;
+ uint32_t unknown1;
+} itunesdb_mhia_t;
+
+typedef struct {
uint8_t unknown; /* zero padded. */
-} chunk_mhlt_t;
+} itunesdb_mhlt_t;
typedef struct {
uint32_t num_children;
@@ -119,11 +130,11 @@
uint32_t unk38;
uint16_t gapless_track;
uint16_t gapless_album;
-} chunk_mhit_t;
+} itunesdb_mhit_t;
typedef struct {
uint8_t unknown; /* zero padded. */
-} chunk_mhlp_t;
+} itunesdb_mhlp_t;
typedef struct {
uint32_t num_mhod;
@@ -138,7 +149,7 @@
uint16_t unk4;
uint16_t flag_podcast;
uint32_t sort_order;
-} chunk_mhyp_t;
+} itunesdb_mhyp_t;
typedef struct {
uint32_t num_mhod;
@@ -147,7 +158,7 @@
uint32_t track_id;
uint32_t timestamp;
uint32_t podcast_parent;
-} chunk_mhip_t;
+} itunesdb_mhip_t;
typedef struct {
uint32_t position;
@@ -155,25 +166,25 @@
uint32_t unknown;
uint32_t unk4;
ucs2char_t* value;
-} chunk_mhod_string_t;
+} itunesdb_mhod_string_t;
typedef struct {
char* value;
-} chunk_mhod_url_t;
+} itunesdb_mhod_url_t;
typedef struct {
uint32_t type;
uint32_t num_entries;
uint8_t padding[40];
uint32_t* entries;
-} chunk_mhod_index_t;
+} itunesdb_mhod_index_t;
typedef struct {
uint16_t id;
uint16_t width;
uint32_t sort_direction;
uint64_t padding;
-} chunk_mhod_playlist_column_definition_t;
+} itunesdb_mhod_playlist_column_definition_t;
typedef struct {
uint32_t unk1;
@@ -186,26 +197,41 @@
uint32_t sort_type;
uint32_t num_columns;
uint32_t unknown;
- chunk_mhod_playlist_column_definition_t* columns;
-} chunk_mhod_playlist_column_t;
+ itunesdb_mhod_playlist_column_definition_t* columns;
+} itunesdb_mhod_playlist_column_t;
typedef struct {
+ uint32_t unknown1;
+ uint32_t unknown2;
+ uint32_t unknown3;
+} itunesdb_mhod_library_playlist_entry_t;
+
+typedef struct {
+ uint32_t type;
+ uint32_t num_entries;
+ uint32_t unknown1;
+ uint32_t unknown2;
+ itunesdb_mhod_library_playlist_entry_t *entries;
+} itunesdb_mhod_library_playlist_index_t;
+
+typedef struct {
uint32_t position;
uint8_t unknown[16];
-} chunk_mhod_playlist_order_t;
+} itunesdb_mhod_playlist_order_t;
typedef struct {
uint32_t type;
uint32_t unk1;
uint32_t unk2;
union {
- chunk_mhod_string_t str;
- chunk_mhod_url_t url;
- chunk_mhod_index_t index;
- chunk_mhod_playlist_column_t pc;
- chunk_mhod_playlist_order_t po;
+ itunesdb_mhod_string_t str;
+ itunesdb_mhod_url_t url;
+ itunesdb_mhod_index_t index;
+ itunesdb_mhod_playlist_column_t pc;
+ itunesdb_mhod_playlist_order_t po;
+ itunesdb_mhod_library_playlist_index_t lp_index;
} data;
-} chunk_mhod_t;
+} itunesdb_mhod_t;
struct tag_itunesdb_chunk {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|