From: <ny...@us...> - 2006-12-25 14:34:05
|
Revision: 200 http://svn.sourceforge.net/pmplib/?rev=200&view=rev Author: nyaochi Date: 2006-12-25 06:33:57 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Implemented a record constructor for db.dat. Not tested yet. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/dat.h trunk/pmplib/lib/pmp_iriverplus3/dic.c trunk/pmplib/lib/pmp_iriverplus3/dic.h trunk/pmplib/lib/pmp_iriverplus3/idx.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-25 14:33:57 UTC (rev 200) @@ -39,6 +39,7 @@ #include <stdlib.h> #include <memory.h> #include <ucs2char.h> +#include <filepath.h> #include "serialize.h" #include "util.h" @@ -139,6 +140,12 @@ memset(list, 0, sizeof(*list)); } +static dat_entry_t *dat_list_expand(dat_list_t* list) +{ + list->entries = (dat_entry_t*)realloc(list->entries, sizeof(dat_entry_t) * (list->num_entries+1)); + return &list->entries[list->num_entries++]; +} + static void dat_list_finish(dat_list_t* list) { uint32_t i; @@ -230,3 +237,160 @@ dat_list_dump(&dat->musics, &dic->music, fp); fprintf(fp, "}\n"); } + +static int comp_pathname(const void *__x, const void *__y) +{ + const ip3db_sort_index_t* _x = (const ip3db_sort_index_t*)__x; + const ip3db_sort_index_t* _y = (const ip3db_sort_index_t*)__y; + const ip3db_variant_t* x = _x->base[_x->index]; + const ip3db_variant_t* y = _y->base[_y->index]; + int ret = ucs2cmp(x[IP3DBF_MUSIC_FILEPATH].value.str, y[IP3DBF_MUSIC_FILEPATH].value.str); + if (ret == 0) { + return ucs2cmp(x[IP3DBF_MUSIC_FILENAME].value.str, y[IP3DBF_MUSIC_FILENAME].value.str); + } else { + return ret; + } +} + +typedef struct { + ucs2char_t* path; + uint32_t uid; +} dircache_element_t; + +typedef struct { + int max_elems; + int num_elems; + dircache_element_t* elems; +} dircache_t; + +static void dircache_init(dircache_t* dc) +{ + memset(dc, 0, sizeof(*dc)); +} + +static void dircache_push(dircache_t* dc, const ucs2char_t* path, uint32_t uid) +{ + dircache_element_t* elem = NULL; + + if (dc->max_elems < dc->num_elems + 1) { + dc->elems = (dircache_element_t*)realloc(dc->elems, sizeof(dircache_element_t) * (dc->max_elems+1)); + memset(&dc->elems[dc->max_elems], 0, sizeof(dircache_element_t)); + ++dc->max_elems; + } + + elem = &dc->elems[dc->num_elems++]; + ucs2free(elem->path); + elem->path = ucs2dup(path); + elem->uid = uid; +} + +static void dircache_pop(dircache_t* dc, int i) +{ + ++i; + for (;i < dc->num_elems;++i) { + ucs2free(dc->elems[i].path); + memset(&dc->elems[i], 0, sizeof(dc->elems[0])); + } +} + +static int dircache_findprefix(dircache_t* dc, const ucs2char_t* path) +{ + int i = dc->num_elems; + while (--i >= 0) { + if (ucs2ncmp(path, dc->elems[i].path, ucs2len(dc->elems[i].path)) == 0) { + break; + } + } + return i; +} + +static dircache_element_t *dircache_get(dircache_t* dc, int i) +{ + return &dc->elems[i]; +} + + +void dat_construct(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records) +{ + int i, j; + dat_entry_t* entry; + uint32_t uid = 0; + static const uint32_t uid_root = 0xFFFFFFFF; + static const ucs2char_t ucs2cs_object_root[] = {'/','a','/',0}; + static const ucs2char_t ucs2cs_root[] = {PATHCHAR, 0}; + dat_list_t* dato = &dat->objects; + dat_list_t* datm = &dat->musics; + dircache_t dc; + ip3db_sort_index_t *si = (ip3db_sort_index_t*)malloc(sizeof(ip3db_sort_index_t) * num_records); + + dircache_init(&dc); + + /* Clear all entries. */ + dat_list_finish(dato); + dat_list_finish(datm); + + /* Append an entry for the root directory. */ + entry = dat_list_expand(dato); + dat_entry_init(entry, &dic->objects); + ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], ucs2cs_object_root); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid_root); + + /* Register the root node to the directory cache. */ + dircache_push(&dc, ucs2cs_root, uid_root); + + for (i = 0;i < num_records;++i) { + si[i].base = records; + si[i].index = i; + } + qsort(si, num_records, sizeof(si[0]), comp_pathname); + + for (i = 0;i < num_records;++i) { + const ip3db_variant_t* record = records[si[i].index]; + const ucs2char_t* path = record[IP3DBF_MUSIC_FILEPATH].value.str; + const ucs2char_t* file = record[IP3DBF_MUSIC_FILENAME].value.str; + int i = dircache_findprefix(&dc, path); + const dircache_element_t* com = dircache_get(&dc, i); + const ucs2char_t* p = path + ucs2len(com->path); + uint32_t puid = com->uid; + + dircache_pop(&dc, i); + + while (p && *p) { + ucs2char_t tmp[MAX_PATH]; + const ucs2char_t* q = filepath_skip_one_directory(p); + uid = dato->num_entries; + + ucs2ncpy(tmp, p, q-p); + tmp[q-p] = 0; + + entry = dat_list_expand(dato); + dat_entry_init(entry, &dic->objects); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); + ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 1); + ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], tmp); + + ucs2ncpy(tmp, path, q-path); + tmp[q-path] = 0; + dircache_push(&dc, tmp, uid); + + puid = uid; + p = q; + } + + uid = dato->num_entries; + entry = dat_list_expand(dato); + dat_entry_init(entry, &dic->objects); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_UID], uid); + ip3db_variant_set_dword(&entry->fields[IP3DBF_OBJECTS_PARENTUID], puid); + ip3db_variant_set_word(&entry->fields[IP3DBF_OBJECTS_FILETYPE], 2); + ip3db_variant_set_str(&entry->fields[IP3DBF_OBJECTS_OBJECTNAME], file); + + entry = dat_list_expand(datm); + dat_entry_init(entry, &dic->music); + for (j = 0;j < entry->num_fields;++j) { + ip3db_variant_clone(&entry->fields[j], &record[j]); + } + ip3db_variant_set_dword(&entry->fields[IP3DBF_MUSIC_UID], uid); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.h 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.h 2006-12-25 14:33:57 UTC (rev 200) @@ -49,4 +49,6 @@ size_t dat_serialize(dat_t* dat, const dic_t* dic, uint8_t* buffer, int is_storing); void dat_dump(dat_t* dat, const dic_t* dic, FILE *fp); +void dat_construct(dat_t* dat, dic_t* dic, const ip3db_music_record_t* records, int num_records); + #endif/*__IP3DB_DAT_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.c 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.c 2006-12-25 14:33:57 UTC (rev 200) @@ -64,6 +64,7 @@ {0, 0x0ACE, {IP3DBF_OBJECTS_FILETYPE, IP3DBF_OBJECTS_PARENTUID, IP3DBF_OBJECTS_PROPERTIES}}, }; + static void dic_field_init(dic_field_t* entry) { memset(entry, 0, sizeof(*entry)); @@ -186,9 +187,9 @@ void dic_dump(dic_t* dic, FILE *fp) { fprintf(fp, "===== db.dic =====\n"); - fprintf(fp, "MUSIC {\n"); + fprintf(fp, "MUSIC = {\n"); dic_table_dump(&dic->music, fp); - fprintf(fp, "OBJECTS {\n"); + fprintf(fp, "OBJECTS = {\n"); dic_table_dump(&dic->objects, fp); fprintf(fp, "\n"); } @@ -238,3 +239,191 @@ fprints(fp, "%s", tbl->fields[field].name); } } + +uint8_t *dic_get_template(long* size) +{ + static uint8_t dic_template[] = { + 0x00, 0x00, 0x0B, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xEA, 0x00, 0x00, 0x04, 0x6E, 0x00, 0x00, 0x09, 0x72, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x03, 0x52, + 0x00, 0x4D, 0x00, 0x75, 0x00, 0x73, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, + 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x86, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x65, 0x00, 0x6E, + 0x00, 0x72, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x54, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xBC, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, + 0x00, 0x65, 0x00, 0x50, 0x00, 0x61, 0x00, 0x74, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDA, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, + 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x75, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, + 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x30, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, + 0x00, 0x73, 0x00, 0x65, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x52, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x74, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x76, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, + 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x4E, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x62, + 0x00, 0x65, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8A, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x44, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA2, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x63, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, + 0x00, 0x75, 0x00, 0x72, 0x00, 0x63, 0x00, 0x68, 0x00, 0x61, 0x00, 0x73, 0x00, 0x65, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xEE, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x72, + 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, + 0x00, 0x53, 0x00, 0x74, 0x00, 0x61, 0x00, 0x74, 0x00, 0x75, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, + 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x2C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x69, + 0x00, 0x74, 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6E, + 0x00, 0x67, 0x00, 0x65, 0x00, 0x64, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x67, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x7A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x75, + 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x57, 0x00, 0x41, 0x00, 0x56, 0x00, 0x45, 0x00, 0x43, + 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x6C, 0x00, 0x75, 0x00, 0x73, 0x00, 0x4D, + 0x00, 0x00, 0x00, 0x00, 0x02, 0xAA, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, + 0x00, 0x6C, 0x00, 0x75, 0x00, 0x73, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x02, 0xCE, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, + 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, 0x00, 0x50, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, + 0x02, 0xF8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x72, 0x00, 0x67, + 0x00, 0x52, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x61, 0x00, 0x73, 0x00, 0x65, 0x00, 0x44, + 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x41, + 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x49, 0x00, 0x44, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x61, + 0x00, 0x74, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x65, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x84, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, + 0x00, 0x65, 0x00, 0x6E, 0x00, 0x72, 0x00, 0x65, 0x00, 0x00, 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, + 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x54, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6C, + 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC2, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x41, + 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x54, 0x00, 0x72, 0x00, 0x61, + 0x00, 0x63, 0x00, 0x6B, 0x00, 0x4E, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x62, 0x00, 0x65, 0x00, 0x72, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xF4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, + 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x54, 0x00, 0x72, + 0x00, 0x61, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x4E, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x62, 0x00, 0x65, + 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x04, 0x1A, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x54, + 0x00, 0x69, 0x00, 0x74, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3E, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x72, 0x00, 0x65, + 0x00, 0x00, 0x00, 0x54, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, + 0x00, 0x75, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6B, + 0x00, 0x4E, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x62, 0x00, 0x65, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, + 0x00, 0x00, 0x00, 0x00, 0x04, 0xB0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, + 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x50, 0x00, 0x61, 0x00, 0x74, 0x00, 0x68, 0x00, 0x00, + 0x00, 0x00, 0x04, 0xCE, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x04, 0xE8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x72, 0x00, 0x74, + 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x65, + 0x00, 0x6E, 0x00, 0x72, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x32, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x74, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x56, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, + 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x57, 0x00, 0x69, 0x00, 0x64, + 0x00, 0x74, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x05, 0x7C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x48, + 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x05, 0x9C, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x50, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x05, 0xBE, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x05, 0xD6, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x43, 0x00, 0x6C, 0x00, 0x75, + 0x00, 0x73, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x55, 0x00, 0x49, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, + 0x07, 0x36, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0E, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x2C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, + 0x00, 0x65, 0x00, 0x50, 0x00, 0x61, 0x00, 0x74, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x06, 0x4A, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, + 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x62, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x00, 0x69, 0x00, 0x64, 0x00, 0x74, 0x00, 0x68, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x7C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0x96, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, + 0x00, 0x61, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0xBA, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x57, + 0x00, 0x69, 0x00, 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x06, 0xE0, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, + 0x00, 0x65, 0x00, 0x48, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x53, 0x00, 0x61, + 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x50, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x22, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, + 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, 0x00, 0x65, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x55, + 0x00, 0x49, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xD4, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, + 0x00, 0x65, 0x00, 0x66, 0x00, 0x65, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x63, 0x00, 0x65, + 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x07, 0x8C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x50, 0x00, 0x61, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x43, 0x00, 0x6C, + 0x00, 0x75, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x07, 0xB2, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x43, 0x00, 0x68, 0x00, 0x69, 0x00, 0x6C, + 0x00, 0x64, 0x00, 0x43, 0x00, 0x6C, 0x00, 0x75, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, + 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, + 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x69, + 0x00, 0x64, 0x00, 0x65, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x08, 0x24, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x53, + 0x00, 0x61, 0x00, 0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, + 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x08, 0x4A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x42, 0x00, 0x69, 0x00, 0x74, + 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x08, 0x62, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x00, 0x69, 0x00, 0x64, 0x00, 0x74, 0x00, 0x68, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x7C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x08, 0xA2, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x61, + 0x00, 0x6C, 0x00, 0x42, 0x00, 0x69, 0x00, 0x74, 0x00, 0x52, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, + 0x00, 0x00, 0x00, 0x00, 0x08, 0xC8, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, + 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6F, 0x00, 0x42, 0x00, 0x69, 0x00, 0x74, 0x00, 0x52, + 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x09, 0x06, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x73, + 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x54, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x73, + 0x00, 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x53, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x6E, + 0x00, 0x64, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x09, 0x34, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x56, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6F, 0x00, 0x46, 0x00, 0x6F, + 0x00, 0x75, 0x00, 0x72, 0x00, 0x43, 0x00, 0x43, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, + 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x09, 0x5E, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x57, 0x00, 0x41, 0x00, 0x56, + 0x00, 0x45, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x55, 0x00, 0x49, 0x00, 0x44, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x09, 0x9A, 0x00, 0x00, 0x0A, 0xCE, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, + 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x09, 0xAE, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x49, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x09, 0xCE, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x61, 0x00, 0x72, + 0x00, 0x65, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x55, 0x00, 0x69, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, + 0x09, 0xF0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F, + 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x65, 0x00, 0x73, 0x00, 0x00, + 0x00, 0x00, 0x0A, 0x0E, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x54, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x0A, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, + 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, + 0x00, 0x00, 0x0A, 0x46, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x61, + 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x64, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, + 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x82, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x44, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x43, 0x00, 0x72, 0x00, 0x65, 0x00, 0x61, + 0x00, 0x00, 0x00, 0x00, 0x0A, 0x9A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, + 0x00, 0x6F, 0x00, 0x77, 0x00, 0x49, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xB4, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x55, 0x00, 0x4F, 0x00, 0x49, 0x00, 0x44, + 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x50, 0x00, 0x55, 0x00, 0x4F, 0x00, 0x49, 0x00, 0x44, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, + 0x00, 0x65, 0x00, 0x54, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x00, 0x00, 0x50, 0x00, 0x61, + 0x00, 0x72, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x55, 0x00, 0x69, 0x00, 0x64, 0x00, 0x00, + 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, + 0x00, 0x65, 0x00, 0x73, 0x00, 0x00, + }; + if (size) { + *size = sizeof(dic_template) / sizeof(dic_template[0]); + } + return dic_template; +} Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dic.h 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/dic.h 2006-12-25 14:33:57 UTC (rev 200) @@ -56,5 +56,6 @@ void dic_dump(dic_t* dic, FILE *fp); uint32_t dic_get_idxroot(dic_t* dic, int table, int index); void dic_repr_index(dic_t* dic, int table, int index, FILE *fp); +uint8_t *dic_get_template(long* size); #endif/*__IP3DB_DIC_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2006-12-25 14:33:57 UTC (rev 200) @@ -284,3 +284,4 @@ fprintf(fpo, "\n"); return 0; } + Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2006-12-25 14:33:57 UTC (rev 200) @@ -50,11 +50,66 @@ ip3db_variant_init(var, IP3DBVT_NONE); } +void ip3db_variant_set_byte(ip3db_variant_t* var, uint8_t val) +{ + var->type = IP3DBVT_BYTE; + var->value.byte = val; +} + +void ip3db_variant_set_word(ip3db_variant_t* var, uint16_t val) +{ + var->type = IP3DBVT_WORD; + var->value.word = val; +} + +void ip3db_variant_set_dword(ip3db_variant_t* var, uint32_t val) +{ + var->type = IP3DBVT_DWORD; + var->value.dword = val; +} + +void ip3db_variant_set_str(ip3db_variant_t* var, const ucs2char_t* val) +{ + var->type = IP3DBVT_STRING; + ucs2free(var->value.str); + var->value.str = ucs2dup(val); +} + +void ip3db_variant_clone(ip3db_variant_t* dst, const ip3db_variant_t* src) +{ + switch (dst->type = src->type) { + case IP3DBVT_BYTE: + dst->value.byte = src->value.byte; + break; + case IP3DBVT_WORD: + dst->value.word = src->value.word; + break; + case IP3DBVT_DWORD: + dst->value.dword = src->value.dword; + break; + case IP3DBVT_STRING: + ucs2free(dst->value.str); + if (src->value.str) { + dst->value.str = ucs2dup(src->value.str); + } else { + dst->value.str = 0; + } + break; + } +} + void ip3db_init(ip3db_t* db) { + uint8_t *dic_template = NULL; + memset(db, 0, sizeof(*db)); db->dat = dat_new(); db->dic = dic_new(); + + dic_template = dic_get_template(&db->dic_size); + db->dic_buffer = (uint8_t*)malloc(db->dic_size); + memcpy(db->dic_buffer, dic_template, db->dic_size); + dic_serialize(db->dic, db->dic_buffer, 0); } void ip3db_finish(ip3db_t* db) @@ -120,3 +175,26 @@ idx_dump(db->idx_buffer, db->dic, fpo); return 0; } + +result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records) +{ + /* Construct Objects table in db.dat */ + dat_construct(db->dat, db->dic, records, num_records); + + /* Construct Music table in db.dat */ + + /* Construct db.idx */ + + /* Update db.dic */ + + return 0; +} + +void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record) +{ + int i; + ip3db_variant_t* var = (ip3db_variant_t*)record; + for (i = 0;i < IP3DBF_MUSIC_LAST;++i) { + ip3db_variant_init(&var[i], db->dic->music.fields[i].type); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2006-12-25 14:33:57 UTC (rev 200) @@ -84,6 +84,14 @@ IP3DBF_MUSIC_LAST, }; +typedef ip3db_variant_t ip3db_music_record_t[IP3DBF_MUSIC_LAST]; + +typedef struct { + const ip3db_music_record_t* base; + int index; +} ip3db_sort_index_t; + + enum { IP3DBF_OBJECTS_NONE = -1, IP3DBF_OBJECTS_BEGIN = 0, @@ -149,14 +157,23 @@ dat_t* dat; dic_t* dic; + } ip3db_t; void ip3db_variant_init(ip3db_variant_t* var, int type); void ip3db_variant_finish(ip3db_variant_t* var); +void ip3db_variant_set_byte(ip3db_variant_t* var, uint8_t val); +void ip3db_variant_set_word(ip3db_variant_t* var, uint16_t val); +void ip3db_variant_set_dword(ip3db_variant_t* var, uint32_t val); +void ip3db_variant_set_str(ip3db_variant_t* var, const ucs2char_t* val); +void ip3db_variant_clone(ip3db_variant_t* dst, const ip3db_variant_t* src); void ip3db_init(ip3db_t* db); void ip3db_finish(ip3db_t* db); result_t ip3db_read(ip3db_t* db, const ucs2char_t* datfn, const ucs2char_t* dicfn, const ucs2char_t* idxfn); result_t ip3db_dump(ip3db_t* db, FILE *fpo); +void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record); +result_t ip3db_set(ip3db_t* db, const ip3db_music_record_t* records, int num_records); + #endif /*_IP3DB_IP3DB_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2006-12-25 07:46:57 UTC (rev 199) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2006-12-25 14:33:57 UTC (rev 200) @@ -65,7 +65,7 @@ "iriver_e10_ums_1.04", "E10 UMS", "UM", "1.04", "1.04", "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", - "\\", "Playlists\\", + "", "Playlists\\", ".plp", }, { @@ -503,9 +503,30 @@ static result_t pmpdb_set(pmpdb_t* pmpdb, const pmp_record_t* records, uint32_t num_records) { + int i; pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return PMP_NOTIMPLIMENTED; + ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmpi->env.path_to_root)+1)); + + ip3db_music_record_t* array = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); + + ucs2cpy(path_to_root, pmpi->env.path_to_root); + filepath_removeslash(path_to_root); + + for (i = 0;i < num_records;++i) { + const pmp_record_t* src = &records[i]; + ip3db_variant_t* dst = array[i]; + + ip3db_record_init(&pmpdbi->ip3db, &array[i]); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], src->filename + ucs2len(path_to_root)); + filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_encode(dst[IP3DBF_MUSIC_FILEPATH].value.str); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILENAME], filepath_skippath(src->filename)); + } + ip3db_set(&pmpdbi->ip3db, array, num_records); + free(array); + return 0; //return ip2db_set(&pmpdbi->ip2db, records, num_records, pmpi->env.path_to_root); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |