From: <ny...@us...> - 2007-01-18 15:06:28
|
Revision: 270 http://svn.sourceforge.net/pmplib/?rev=270&view=rev Author: nyaochi Date: 2007-01-18 07:06:25 -0800 (Thu, 18 Jan 2007) Log Message: ----------- Incremental commit before starting additional E10 database analysis for playlists. Pleylists seem to be integrated in the database although iriver plus 3 generates *.plp file in \Playlists directory. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.h trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj Added Paths: ----------- trunk/pmplib/lib/pmp_iriverplus3/plp.c Removed Paths: ------------- trunk/pmplib/lib/pmp_iriverplus3/playlist.c Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-18 15:06:25 UTC (rev 270) @@ -75,24 +75,24 @@ ) { int result = 0; - /* int i, j, num_succeeded = 0; char *mbs = NULL; - pmp_playlist_t* pmppl = NULL; + pmp_music_t* music = NULL; playlist_mediafile_t* mediafiles = NULL; + pmp_playlist_t* pmppls = NULL; + int num_pmppls = 0; result_t res = 0; callback_data_t cd; + ucs2char_t dstpath[MAX_PATH]; cd.instance = instance; cd.progress = progress; - // Create playlist instance. - res = pmp->create_instance_pl(pmp, &pmppl); - if (!pmppl) { - result = MAKE_PMP_ERROR(res); - goto error_exit; - } + // Query the interface to music. + music = pmp->music; + filepath_combinepath(dstpath, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); + // Start playlist processing. if (progress(instance, EASYPMPPLP_START, 0, 0, NULL) != 0) { result = EASYPMPE_CANCEL; @@ -160,11 +160,11 @@ ucs2char_t** contents = NULL; playlist_t* pl = &pls.playlists[k]; ucs2char_t dst[MAX_PATH]; + pmp_playlist_t* pmppl = NULL; // Generate a destination filename. - filepath_combinepath(dst, MAX_PATH, pmp->env.path_to_playlist.path, filepath_skippath(pl->name)); + filepath_combinepath(dst, MAX_PATH, dstpath, filepath_skippath(pl->name)); filepath_remove_extension(dst); - ucs2cat(dst, pmp->env.playlist_ext); // Skipping the existing playlist if (!(opt->verb & MODE_PLAYLIST_RECONVERT)) { @@ -186,7 +186,7 @@ n = playlist_normalize( pl, filepath_skippath(pl->name), - pmp->env.path_to_root.path, + pmp->info.path_to_root, mediafiles, musics->num_elements ); @@ -221,31 +221,32 @@ } } + pmppls = (pmp_playlist_t*)realloc(pmppls, sizeof(pmp_playlist_t) * (num_pmppls+1)); + pmppl = &pmppls[num_pmppls]; + // Allocate a memory block for the contents of the playlist. - contents = (ucs2char_t**)calloc(pl->num_entries, sizeof(ucs2char_t*)); - if (!contents) { + pmppl->entries = (ucs2char_t**)calloc(pl->num_entries, sizeof(ucs2char_t*)); + pmppl->num_entries = pl->num_entries; + pmppl->name = ucs2dup(dst); + + if (!pmppl->entries) { result = EASYPMPE_INSUFFICIENT_MEMORY; goto error_exit; } for (j = 0, n = 0;j < pl->num_entries;++j) { if (pl->entries[j].valid && pl->entries[j].filename[0]) { - contents[n] = ucs2dup(pl->entries[j].filename); + pmppl->entries[n] = ucs2dup(pl->entries[j].filename); ++n; } } - // Write the converted playlist. - pmppl->write(pmppl, dst, contents, n); ++num_succeeded; - - // Free the contents of the playlist. - for (j = 0;j < n;++j) { - ucs2free(contents[j]); - } - free(contents); + ++num_pmppls; } } + music->set_playlists(music, pmppls, num_pmppls); + // Finish playlist conversion. if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { result = EASYPMPE_CANCEL; @@ -259,12 +260,11 @@ } error_exit: + for (i = 0;i < num_pmppls;++i) { + pmp_playlist_finish(&pmppls[i]); + } + free(pmppls); free(mediafiles); - if (pmppl) { - pmppl->release(pmppl); - pmppl = NULL; - } - */ return result; } /** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-18 15:06:25 UTC (rev 270) @@ -336,6 +336,10 @@ openflag |= PMPOF_MUSIC_DB_READ; } + if (opt.verb & MODE_PLAYLIST) { + openflag |= PMPOF_MUSIC_PL_WRITE; + } + // Open the PMP. ret = pmp->open(pmp, openflag); @@ -394,7 +398,7 @@ free(records); } - pmp->close(pmp, 0); + pmp->close(pmp); pmp->release(pmp); pmplib_finish(pmphelp); option_finish(&opt); Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/include/pmp.h 2007-01-18 15:06:25 UTC (rev 270) @@ -271,9 +271,8 @@ /** * Close the PMP device. * @param pmp The pointer to the pmp_t instance. - * @param flag The close flags. */ - result_t (*close)(pmp_t* pmp, uint32_t flag); + result_t (*close)(pmp_t* pmp); }; typedef void pmpdb_readwrite_progress_t(void *instance, uint32_t size, uint32_t total); @@ -304,13 +303,9 @@ typedef struct tag_pmp_music_record_t pmp_music_record_t; typedef struct { - ucs2char_t filename[MAX_PATH]; -} pmp_playlist_entry_t; - -typedef struct { - ucs2char_t name[MAX_PATH]; + ucs2char_t *name; int num_entries; - pmp_playlist_entry_t* entries; + ucs2char_t **entries; } pmp_playlist_t; struct tag_pmp_music_t { @@ -341,11 +336,13 @@ PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); +PMPAPI void pmp_playlist_init(pmp_playlist_t* playlist); +PMPAPI void pmp_playlist_finish(pmp_playlist_t* playlist); +PMPAPI void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src); - /** * @defgroup pmplib PMPlib Helper API * Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-18 15:06:25 UTC (rev 270) @@ -62,3 +62,30 @@ dst->date = src->date ? ucs2dup(src->date) : NULL; return 0; } + +void pmp_playlist_init(pmp_playlist_t* playlist) +{ + memset(playlist, 0, sizeof(*playlist)); +} + +void pmp_playlist_finish(pmp_playlist_t* playlist) +{ + int i; + for (i = 0;i < playlist->num_entries;++i) { + ucs2free(playlist->entries[i]); + } + ucs2free(playlist->entries); + ucs2free(playlist->name); +} + +void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src) +{ + int i; + + dst->name = ucs2dup(src->name); + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2calloc(sizeof(ucs2char_t*) * src->num_entries); + for (i = 0;i < src->num_entries;++i) { + dst->entries[i] = ucs2dup(src->entries[i]); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-18 15:06:25 UTC (rev 270) @@ -29,12 +29,14 @@ #include <stdio.h> #include <stdlib.h> #include <ucs2char.h> +#include <filepath.h> #include "util.h" #include "ip3db.h" #include "dic.h" #include "dat.h" #include "idx.h" +#include "plp.h" void ip3db_variant_init(ip3db_variant_t* var, int type) { @@ -247,3 +249,51 @@ ip3db_variant_finish(&var[i]); } } + +void ip3db_playlist_init(ip3db_playlist_t* playlist) +{ + memset(playlist, 0, sizeof(*playlist)); +} + +void ip3db_playlist_finish(ip3db_playlist_t* playlist) +{ + int i; + for (i = 0;i < playlist->num_entries;++i) { + ucs2free(playlist->entries[i]); + } + ucs2free(playlist->entries); + ucs2free(playlist->filepath); + ucs2free(playlist->filename); +} + +void ip3db_playlist_copy(ip3db_playlist_t* dst, const ip3db_playlist_t* src) +{ + int i; + + dst->filepath = ucs2dup(src->filepath); + dst->filename = ucs2dup(src->filename); + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2calloc(sizeof(ucs2char_t*) * src->num_entries); + for (i = 0;i < src->num_entries;++i) { + dst->entries[i] = ucs2dup(src->entries[i]); + } +} + +int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root) +{ + int i; + + for (i = 0;i < num_playlists;++i) { + ucs2char_t filename[MAX_PATH]; + const ip3db_playlist_t* pl = &playlists[i]; + + ucs2cpy(filename, path_to_root); + ucs2cat(filename, pl->filepath + 1); + ucs2cat(filename, pl->filename); + filepath_backslash(filename); + + plp_write(db, filename, pl->entries, pl->num_entries, path_to_root); + } + + return 0; +} Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.h 2007-01-18 15:06:25 UTC (rev 270) @@ -55,6 +55,8 @@ typedef struct { ucs2char_t* filepath; ucs2char_t* filename; + int num_entries; + ucs2char_t **entries; } ip3db_playlist_t; /** @@ -189,15 +191,14 @@ int ip3db_num_records(ip3db_t* db); ip3db_music_record_t* ip3db_get_record(ip3db_t* db, int i); result_t ip3db_dump(ip3db_t* db, FILE *fpo); -int ip3db_playlist_write( - ip3db_t* db, - const ucs2char_t *filename, - ucs2char_t* const mediafiles[], - int num_mediafiles, - const ucs2char_t *path_to_root - ); +int ip3db_write_playlists(ip3db_t* db, const ip3db_playlist_t* playlists, int num_playlists, const ucs2char_t *path_to_root); + void ip3db_record_init(ip3db_t* db, ip3db_music_record_t* record); void ip3db_record_finish(ip3db_t* db, ip3db_music_record_t* record); +void ip3db_playlist_init(ip3db_playlist_t* playlist); +void ip3db_playlist_finish(ip3db_playlist_t* playlist); +void ip3db_playlist_copy(ip3db_playlist_t* dst, const ip3db_playlist_t* src); + #endif /*_IP3DB_IP3DB_H__*/ Deleted: trunk/pmplib/lib/pmp_iriverplus3/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/playlist.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/playlist.c 2007-01-18 15:06:25 UTC (rev 270) @@ -1,120 +0,0 @@ -/* - * Playlist reader/writer for iriver E10. - * - * Copyright (c) 2005-2006 Nyaochi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif/*HAVE_CONFIG_H*/ - -#include <os.h> -#include <stdio.h> -#include <stdlib.h> -#include <ucs2char.h> -#include <filepath.h> - -#include "serialize.h" -#include "util.h" -#include "ip3db.h" -#include "dat.h" - -static uint32_t findfile(ip3db_t* db, const ucs2char_t *filename, const ucs2char_t *path_to_root) -{ - int i; - const ucs2char_t *filepart = filepath_skippath(filename); - const ucs2char_t *pathfile = filepath_skipdrive(filename, path_to_root); - ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(pathfile) + 1)); - - ucs2cpy(pathname, pathfile); - filepath_remove_filespec(pathname); - filepath_addslash(pathname); - filepath_slash(pathname); - - for (i = 0;i < db->dat->musics.num_entries;++i) { - dat_entry_t* entry = &db->dat->musics.entries[i]; - if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && - ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { - return entry->fields[IP3DBF_MUSIC_UID].value.dword; - } - } - return 0; -} - -int ip3db_playlist_write( - ip3db_t* db, - const ucs2char_t *filename, - ucs2char_t* const mediafiles[], - int num_mediafiles, - const ucs2char_t *path_to_root - ) -{ - int i; - FILE *fp = NULL; - uint32_t* uids = NULL; - uint32_t num_uids = 0; - - for (i = 0;i < num_mediafiles;i++) { - if (mediafiles[i][0]) { - uint32_t uid = 0; - ucs2char_t mediafile[MAX_PATH]; - ucs2cpy(mediafile, mediafiles[i]); - - uid = findfile(db, mediafile, path_to_root); - if (uid <= 0) { - goto error_exit; - } - - uids = realloc(uids, sizeof(uint32_t) * (num_uids+1)); - if (!uids) { - goto error_exit; - } - uids[num_uids++] = uid; - } - } - - fp = ucs2fopen(filename, "wb"); - if (fp) { - size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_uids; - uint8_t* buffer = (uint8_t*)malloc(size); - uint8_t* p = buffer; - - if (!buffer) { - goto error_exit; - } - - p += serialize_uint32le(p, &num_uids, 1); - for (i = 0;i < (int)num_uids;++i) { - p += serialize_uint32le(p, &uids[i], 1); - } - fwrite(buffer, 1, size, fp); - free(buffer); - fclose(fp); - } else { - return -1; - } - - free(uids); - return 0; - -error_exit: - free(uids); - return -1; -} Copied: trunk/pmplib/lib/pmp_iriverplus3/plp.c (from rev 263, trunk/pmplib/lib/pmp_iriverplus3/playlist.c) =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/plp.c (rev 0) +++ trunk/pmplib/lib/pmp_iriverplus3/plp.c 2007-01-18 15:06:25 UTC (rev 270) @@ -0,0 +1,120 @@ +/* + * Playlist reader/writer for iriver E10. + * + * Copyright (c) 2005-2006 Nyaochi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif/*HAVE_CONFIG_H*/ + +#include <os.h> +#include <stdio.h> +#include <stdlib.h> +#include <ucs2char.h> +#include <filepath.h> + +#include "serialize.h" +#include "util.h" +#include "ip3db.h" +#include "dat.h" + +static uint32_t findfile(ip3db_t* db, const ucs2char_t *filename, const ucs2char_t *path_to_root) +{ + int i; + const ucs2char_t *filepart = filepath_skippath(filename); + const ucs2char_t *pathfile = filepath_skipdrive(filename, path_to_root); + ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(pathfile) + 1)); + + ucs2cpy(pathname, pathfile); + filepath_remove_filespec(pathname); + filepath_addslash(pathname); + filepath_slash(pathname); + + for (i = 0;i < db->dat->musics.num_entries;++i) { + dat_entry_t* entry = &db->dat->musics.entries[i]; + if (ucs2icmp(entry->fields[IP3DBF_MUSIC_FILENAME].value.str, filepart) == 0 && + ucs2icmp(entry->fields[IP3DBF_MUSIC_FILEPATH].value.str, pathname) == 0) { + return entry->fields[IP3DBF_MUSIC_UID].value.dword; + } + } + return 0; +} + +int plp_write( + ip3db_t* db, + const ucs2char_t *filename, + ucs2char_t* const mediafiles[], + int num_mediafiles, + const ucs2char_t *path_to_root + ) +{ + int i; + FILE *fp = NULL; + uint32_t* uids = NULL; + uint32_t num_uids = 0; + + for (i = 0;i < num_mediafiles;i++) { + if (mediafiles[i][0]) { + uint32_t uid = 0; + ucs2char_t mediafile[MAX_PATH]; + ucs2cpy(mediafile, mediafiles[i]); + + uid = findfile(db, mediafile, path_to_root); + if (uid <= 0) { + goto error_exit; + } + + uids = realloc(uids, sizeof(uint32_t) * (num_uids+1)); + if (!uids) { + goto error_exit; + } + uids[num_uids++] = uid; + } + } + + fp = ucs2fopen(filename, "wb"); + if (fp) { + size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_uids; + uint8_t* buffer = (uint8_t*)malloc(size); + uint8_t* p = buffer; + + if (!buffer) { + goto error_exit; + } + + p += serialize_uint32le(p, &num_uids, 1); + for (i = 0;i < (int)num_uids;++i) { + p += serialize_uint32le(p, &uids[i], 1); + } + fwrite(buffer, 1, size, fp); + free(buffer); + fclose(fp); + } else { + return -1; + } + + free(uids); + return 0; + +error_exit: + free(uids); + return -1; +} Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-18 15:06:25 UTC (rev 270) @@ -71,7 +71,7 @@ "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "", "Playlists\\", + "System\\", "Music2\\", "Playlists\\", ".plp", }, { @@ -100,7 +100,7 @@ static uint32_t pmp_add_ref(pmp_t* pmp); static uint32_t pmp_release(pmp_t* pmp); static result_t pmp_open(pmp_t* pmp, uint32_t flag); -static result_t pmp_close(pmp_t* pmp, uint32_t flag); +static result_t pmp_close(pmp_t* pmp); static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); static uint32_t pmpmusic_release(pmp_music_t* pmpdb); @@ -416,17 +416,29 @@ return 0; } -static result_t pmp_close(pmp_t* pmp, uint32_t flag) +static result_t pmp_close(pmp_t* pmp) { result_t ret = 0; - if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + + // Music database/playlist. + if (pmp->flag & PMPOF_MUSIC_DB_WRITE || pmp->flag & PMPOF_MUSIC_PL_WRITE) { ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + // Register records (and playlists) to the database. + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + } else { + ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, NULL, 0); + } + // Write out the playlist first. + ip3db_write_playlists(&pmpmi->ip3db, pmpmi->playlists, pmpmi->num_playlists, pmp->info.path_to_root); + + // Write out the music database. set_filenames(dat, dic, idx, pmp); - return ip3db_write(&pmpmi->ip3db, dat, dic, idx); + ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); + } return 0; } @@ -605,14 +617,44 @@ } } -static result_t pmpmusic_set_playlists(pmp_music_t* pmpmusic, const pmp_playlist_t* playlists, uint32_t num_playlists) +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists) { - /* - pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; - if (ip3db_playlist_write(&pmppli->ip3db, filename, files, num_files, pmpi->env.path_to_root) != 0) { - return PMPPLE_WRITE; + uint32_t i, j; + static const ucs2char_t plp_ext[] = {'.','p','l','p',0}; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + // Free playlists attached to pmpmi. + for (i = 0;i < pmpmi->num_playlists;++i) { + ip3db_playlist_finish(&pmpmi->playlists[i]); } - */ + free(pmpmi->playlists); + + // Allocate a new playlists. + pmpmi->playlists = (ip3db_playlist_t*)calloc(num_playlists, sizeof(ip3db_playlist_t)); + pmpmi->num_playlists = num_playlists; + + // Copy the content of the playlists. + for (i = 0;i < num_playlists;++i) { + ucs2char_t filepath[MAX_PATH]; + const pmp_playlist_t* src = &playlists[i]; + ip3db_playlist_t* dst = &pmpmi->playlists[i]; + + ucs2cpy(filepath, src->name); + ucs2cat(filepath, plp_ext); + + dst->filename = ucs2dup(filepath_skippath(filepath)); + + filepath_remove_filespec(filepath); + filepath_addslash(filepath); + dst->filepath = ucs2dup(filepath_skipdrive(filepath, music->pmp->info.path_to_root)); + filepath_slash(dst->filepath); + + dst->num_entries = src->num_entries; + dst->entries = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * src->num_entries); + for (j = 0;j < src->num_entries;++j) { + dst->entries[j] = ucs2dup(src->entries[j]); + } + } + return 0; } Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-17 19:24:46 UTC (rev 269) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.vcproj 2007-01-18 15:06:25 UTC (rev 270) @@ -193,7 +193,7 @@ > </File> <File - RelativePath=".\playlist.c" + RelativePath=".\plp.c" > </File> <File @@ -231,6 +231,10 @@ > </File> <File + RelativePath=".\plp.h" + > + </File> + <File RelativePath=".\serialize.h" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-25 02:29:25
|
Revision: 275 http://svn.sourceforge.net/pmplib/?rev=275&view=rev Author: nyaochi Date: 2007-01-24 18:29:25 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Synchronize pmp_iriverplus3 with the latest API spec. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/ip3db.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 02:29:25 UTC (rev 275) @@ -211,7 +211,7 @@ if (begin + 1 == end) { // If the time stamps are identical, let us skip this file. if (old_records[begin].ts_update == timestamp) { - pmp_record_copy(record, &old_records[begin]); + pmp_record_clone(record, &old_records[begin]); is_skipping = 1; } } Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/include/pmp.h 2007-01-25 02:29:25 UTC (rev 275) @@ -416,7 +416,10 @@ PMPAPI void pmp_record_init(pmp_music_record_t* record); PMPAPI void pmp_record_finish(pmp_music_record_t* record); -PMPAPI result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src); +PMPAPI result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src); +PMPAPI void pmp_records_finish(pmp_music_record_t* records, int num_records); +PMPAPI result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); + PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-25 02:29:25 UTC (rev 275) @@ -51,7 +51,7 @@ pmp_record_init(record); } -result_t pmp_record_copy(pmp_music_record_t* dst, const pmp_music_record_t* src) +result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src) { memcpy(dst, src, sizeof(*src)); dst->filename = src->filename ? ucs2dup(src->filename) : NULL; @@ -63,6 +63,23 @@ return 0; } +void pmp_records_finish(pmp_music_record_t* records, int num_records) +{ + int i; + for (i = 0;i < num_records;++i) { + pmp_record_finish(&records[i]); + } + ucs2free(records); +} + +result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records) +{ + int i; + for (i = 0;i < num_records;++i) { + pmp_record_clone(&dst[i], &src[i]); + } +} + void pmp_playlist_init(pmp_playlist_t* playlist) { memset(playlist, 0, sizeof(*playlist)); Modified: trunk/pmplib/lib/pmp_iriverplus3/ip3db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp_iriverplus3/ip3db.c 2007-01-25 02:29:25 UTC (rev 275) @@ -36,7 +36,6 @@ #include "dic.h" #include "dat.h" #include "idx.h" -#include "plp.h" void ip3db_variant_init(ip3db_variant_t* var, int type) { Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-24 23:07:42 UTC (rev 274) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-25 02:29:25 UTC (rev 275) @@ -91,7 +91,7 @@ typedef struct { ip3db_t ip3db; - ip3db_music_record_t* records; + pmp_music_record_t* records; int num_records; ip3db_playlist_t* playlists; int num_playlists; @@ -103,11 +103,13 @@ static result_t pmp_close(pmp_t* pmp); static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static uint32_t pmpmusic_release(pmp_music_t* pmpdb); -static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); -static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); -static result_t pmpmusic_dump(pmp_music_t* pmpdb, FILE *fp, int level); -static result_t pmpmusic_set_playlists(pmp_music_t* pmpdb, const pmp_playlist_t* playlists, uint32_t num_playlists); +static uint32_t pmpmusic_release(pmp_music_t* music); +static uint32_t pmpmusic_open(pmp_music_t* music); +static uint32_t pmpmusic_close(pmp_music_t* music); +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records); +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level); +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); #define COMP(a, b) ((a)>(b))-((a)<(b)) @@ -404,15 +406,16 @@ static result_t pmp_open(pmp_t* pmp, uint32_t flag) { result_t ret = 0; + + // Set the open flag. pmp->flag = flag; - if (pmp->flag & PMPOF_MUSIC_DB_READ) { - ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Open the music database. + ret = pmpmusic_open(pmp->music); + if (ret) { + return ret; + } - set_filenames(dat, dic, idx, pmp); - return ip3db_read(&pmpmi->ip3db, dat, dic, idx); - } return 0; } @@ -420,23 +423,12 @@ { result_t ret = 0; - // Music database/playlist. - if (pmp->flag & PMPOF_MUSIC_DB_WRITE || pmp->flag & PMPOF_MUSIC_PL_WRITE) { - ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Close the music database. + ret = pmpmusic_close(pmp->music); + if (ret) { + return ret; + } - // Register records (and playlists) to the database. - if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); - } else { - ip3db_set(&pmpmi->ip3db, pmpmi->records, pmpmi->num_records, NULL, 0); - } - - // Write out the music database. - set_filenames(dat, dic, idx, pmp); - ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); - - } return 0; } @@ -474,18 +466,160 @@ - static uint32_t pmpmusic_release(pmp_music_t* music) { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; ip3db_finish(&pmpmi->ip3db); - free(pmpmi->records); + pmp_records_finish(pmpmi->records, pmpmi->num_records); free(pmpmi->playlists); free(pmpmi); free(music); return 0; } +static uint32_t pmpmusic_open(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + // Free the existing records. + pmp_records_finish(pmpmi->records, pmpmi->num_records); + pmpmi->records = 0; + pmpmi->num_records = 0; + + // Open the music database if necessary. + if (pmp->flag & PMPOF_MUSIC_DB_READ) { + int i; + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + + // Read the music database. + set_filenames(dat, dic, idx, pmp); + ret = ip3db_read(&pmpmi->ip3db, dat, dic, idx); + if (ret) { + return ret; + } + + // The number of music records. + pmpmi->num_records = ip3db_num_records(&pmpmi->ip3db); + + // Allocate an array of the records. + pmpmi->records = (pmp_music_record_t*)malloc(sizeof(pmp_music_record_t) * pmpmi->num_records); + + // Convert IP3DB records to a pmp_music_record_t array. + for (i = 0;i < pmpmi->num_records;++i) { + const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&pmpmi->ip3db, i); + pmp_music_record_t* dst = &pmpmi->records[i]; + size_t length = 0; + + pmp_record_init(dst); + + length = ucs2len(pmp->info.path_to_root); + length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); + length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str); + dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1)); + ucs2cpy(dst->filename, pmp->info.path_to_root); + ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1); + ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str); + filepath_backslash(dst->filename); + + dst->title = ucs2dup(src[IP3DBF_MUSIC_TITLE].value.str); + dst->artist = ucs2dup(src[IP3DBF_MUSIC_ARTIST].value.str); + dst->album = ucs2dup(src[IP3DBF_MUSIC_ALBUM].value.str); + dst->genre = ucs2dup(src[IP3DBF_MUSIC_GENRE].value.str); + dst->date = ucs2dup(src[IP3DBF_MUSIC_ORGRELEASEDATE].value.str); + switch (src[IP3DBF_MUSIC_FILEFORMAT].value.word) { + case 0: + dst->codec = PMPCODEC_MPEGLAYER3; + break; + case 3: + dst->codec = PMPCODEC_VORBIS; + break; + case 5: + dst->codec = PMPCODEC_WMA; + break; + } + dst->track_number = src[IP3DBF_MUSIC_TRACKNUMBER].value.word; + dst->bitrate = src[IP3DBF_MUSIC_BITRATE].value.dword; + dst->duration = src[IP3DBF_MUSIC_DURATION].value.dword; + dst->ts_update = src[IP3DBF_MUSIC_CLUSA].value.dword; + dst->rating = src[IP3DBF_MUSIC_RATING].value.word; + } + } + + return 0; +} + +static uint32_t pmpmusic_close(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + int i; + ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH]; + ip3db_music_record_t* records = NULL; + + // Allocate an array of music records. + records = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * pmpmi->num_records); + + // Build an array of IP3DB records. + for (i = 0;i < pmpmi->num_records;++i) { + const pmp_music_record_t* src = &pmpmi->records[i]; + ip3db_variant_t* dst = records[i]; + + ip3db_record_init(&pmpmi->ip3db, &records[i]); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); + filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); + filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILENAME], filepath_skippath(src->filename)); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ARTIST], src->artist); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ALBUM], src->album); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_GENRE], src->genre); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_TITLE], src->title); + ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_DURATION], src->duration); + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_RATING], (uint16_t)src->rating); + switch (src->codec) { + case PMPCODEC_MPEGLAYER3: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 0); + break; + case PMPCODEC_VORBIS: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 3); + break; + case PMPCODEC_WMA: + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 5); + break; + } + ip3db_variant_set_word(&dst[IP3DBF_MUSIC_TRACKNUMBER], (uint16_t)src->track_number); + ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_BITRATE], src->bitrate); + ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_CLUSA], src->ts_update); + ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); + } + + // Register records (and playlists) to the database. + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + ip3db_set(&pmpmi->ip3db, records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists); + } else { + ip3db_set(&pmpmi->ip3db, records, pmpmi->num_records, NULL, 0); + } + + // Write out the music database. + set_filenames(dat, dic, idx, pmp); + ret = ip3db_write(&pmpmi->ip3db, dat, dic, idx); + + // Free IP3DB records. + for (i = 0;i < pmpmi->num_records;++i) { + ip3db_record_finish(&pmpmi->ip3db, &records[i]); + } + free(records); + } + + return 0; +} + static ucs2char_t* _filepath_removeslash(ucs2char_t* path) { size_t length = ucs2len(path)-1; @@ -496,111 +630,36 @@ return (path + length); } -static result_t pmpmusic_set_records(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records) { - uint32_t i; - pmp_t* pmp = pmpdb->pmp; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; /* Free records attached to pmpmi. */ - for (i = 0;i < (uint32_t)pmpmi->num_records;++i) { - ip3db_record_finish(&pmpmi->ip3db, &pmpmi->records[i]); - } - free(pmpmi->records); + pmp_records_finish(pmpmi->records, pmpmi->num_records); /* Allocate new records. */ - pmpmi->records = (ip3db_music_record_t*)malloc(sizeof(ip3db_music_record_t) * num_records); + pmpmi->records = (pmp_music_record_t*)ucs2malloc(sizeof(pmp_music_record_t) * num_records); pmpmi->num_records = num_records; + pmp_records_clone(pmpmi->records, records, num_records); - for (i = 0;i < num_records;++i) { - const pmp_music_record_t* src = &records[i]; - ip3db_variant_t* dst = pmpmi->records[i]; - - ip3db_record_init(&pmpmi->ip3db, &pmpmi->records[i]); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); - filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); - filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); - filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILENAME], filepath_skippath(src->filename)); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ARTIST], src->artist); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_ALBUM], src->album); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_GENRE], src->genre); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_TITLE], src->title); - ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_DURATION], src->duration); - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_RATING], (uint16_t)src->rating); - switch (src->codec) { - case PMPCODEC_MPEGLAYER3: - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 0); - break; - case PMPCODEC_VORBIS: - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 3); - break; - case PMPCODEC_WMA: - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_FILEFORMAT], 5); - break; - } - ip3db_variant_set_word(&dst[IP3DBF_MUSIC_TRACKNUMBER], (uint16_t)src->track_number); - ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_BITRATE], src->bitrate); - ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_CLUSA], src->ts_update); - ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1); - - } return 0; } -static result_t pmpmusic_get_records(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records) { - pmp_t* pmp = pmpdb->pmp; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmpdb->instance; - ucs2char_t *path_to_root = alloca(sizeof(ucs2char_t) * (ucs2len(pmp->info.path_to_root)+1)); - int i, n = ip3db_num_records(&pmpmi->ip3db); + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; if (!records) { - *num_records = (uint32_t)n; + *num_records = pmpmi->num_records; return 0; + } else if (*num_records == pmpmi->num_records) { + pmp_records_clone(records, pmpmi->records, pmpmi->num_records); + return 0; + } else { + return PMPDBE_INSUFFICIENT; } - - for (i = 0;i < n;++i) { - const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&pmpmi->ip3db, i); - pmp_music_record_t* dst = &records[i]; - size_t length = 0; - - pmp_record_init(dst); - - length = ucs2len(pmp->info.path_to_root); - length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); - length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str); - dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1)); - ucs2cpy(dst->filename, pmp->info.path_to_root); - ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1); - ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str); - filepath_backslash(dst->filename); - - dst->title = ucs2dup(src[IP3DBF_MUSIC_TITLE].value.str); - dst->artist = ucs2dup(src[IP3DBF_MUSIC_ARTIST].value.str); - dst->album = ucs2dup(src[IP3DBF_MUSIC_ALBUM].value.str); - dst->genre = ucs2dup(src[IP3DBF_MUSIC_GENRE].value.str); - dst->date = ucs2dup(src[IP3DBF_MUSIC_ORGRELEASEDATE].value.str); - switch (src[IP3DBF_MUSIC_FILEFORMAT].value.word) { - case 0: - dst->codec = PMPCODEC_MPEGLAYER3; - break; - case 3: - dst->codec = PMPCODEC_VORBIS; - break; - case 5: - dst->codec = PMPCODEC_WMA; - break; - } - dst->track_number = src[IP3DBF_MUSIC_TRACKNUMBER].value.word; - dst->bitrate = src[IP3DBF_MUSIC_BITRATE].value.dword; - dst->duration = src[IP3DBF_MUSIC_DURATION].value.dword; - dst->ts_update = src[IP3DBF_MUSIC_CLUSA].value.dword; - dst->rating = src[IP3DBF_MUSIC_RATING].value.word; - } - return 0; } static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-25 22:16:17
|
Revision: 277 http://svn.sourceforge.net/pmplib/?rev=277&view=rev Author: nyaochi Date: 2007-01-25 14:16:09 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Update API documentations and function names. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h trunk/pmplib/include/gmi.h trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp/pmp_win32.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/pmplib/lib/pmp_portalplayer1/pp1db.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 22:16:09 UTC (rev 277) @@ -201,7 +201,7 @@ } // Initialize the record. - pmp_record_init(record); + pmplib_record_init(record); // Determine if we can skip obtaining a media information from this file. if (opt->verb & MODE_DATABASE_UPDATE) { @@ -211,7 +211,7 @@ if (begin + 1 == end) { // If the time stamps are identical, let us skip this file. if (old_records[begin].ts_update == timestamp) { - pmp_record_clone(record, &old_records[begin]); + pmplib_record_clone(record, &old_records[begin]); is_skipping = 1; } } @@ -275,7 +275,7 @@ */ if (old_records) { for (i = 0;i < num_old_records;++i) { - pmp_record_finish(&old_records[i]); + pmplib_record_finish(&old_records[i]); } free(old_records); } @@ -287,7 +287,7 @@ } else { /* Free the record array. */ for (i = 0;i < fl->num_elements;++i) { - pmp_record_finish(&records[i]); + pmplib_record_finish(&records[i]); } free(records); } Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-25 22:16:09 UTC (rev 277) @@ -261,7 +261,7 @@ error_exit: for (i = 0;i < num_pmppls;++i) { - pmp_playlist_finish(&pmppls[i]); + pmplib_playlist_finish(&pmppls[i]); } free(pmppls); free(mediafiles); Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-25 22:16:09 UTC (rev 277) @@ -393,7 +393,7 @@ /* Free the record array. */ int i; for (i = 0;i < num_records;++i) { - pmp_record_finish(&records[i]); + pmplib_record_finish(&records[i]); } free(records); } Modified: trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-01-25 22:16:09 UTC (rev 277) @@ -438,7 +438,7 @@ /* Free the record array. */ int i; for (i = 0;i < num_records;++i) { - pmp_record_finish(&records[i]); + pmplib_record_finish(&records[i]); } free(records); } @@ -452,7 +452,7 @@ /* Free the record array. */ int i; for (i = 0;i < num_records;++i) { - pmp_record_finish(&records[i]); + pmplib_record_finish(&records[i]); } free(records); } Modified: trunk/pmplib/include/gmi.h =================================================================== --- trunk/pmplib/include/gmi.h 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/include/gmi.h 2007-01-25 22:16:09 UTC (rev 277) @@ -55,7 +55,7 @@ }; #define media_info_t pmp_music_record_t -#define gmi_finish pmp_record_finish +#define gmi_finish pmplib_record_finish GMIAPI int gmi_get( media_info_t* info, Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/include/pmp.h 2007-01-25 22:16:09 UTC (rev 277) @@ -103,19 +103,17 @@ }; /** - * Fourcc representation of codecs. + * Macro to define FourCC representations of codecs. */ #define PMPFOURCC(a, b, c, d) \ ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (uint32_t)(d)) -#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') +#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') /**< Unknown codec. */ #define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') /**< MPEG Audio Layer III */ #define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') /**< Windows Media Audio */ #define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') /**< Ogg Vorbis */ #define PMPCODEC_WAV PMPFOURCC('W','A','V','E') /**< Microsoft Riff WAVE */ -#define PMPMAXCODECS 32 - enum { PMPPEF_NONE = 0x0000, PMPPEF_SUPPORT = 0x0001, @@ -136,6 +134,12 @@ }; + +/** + * @defgroup device PMPlib Device API + * @{ + */ + /** Maximum size, in chars, of a device description. */ #define PMP_DECLSIZE (128) /** Unavailable field of a device description. */ @@ -201,8 +205,6 @@ const pmp_device_description_t decl; } pmp_device_information_t; - - /** * The root interface for portable media device. * @@ -279,30 +281,132 @@ result_t (*close)(pmp_t* pmp); }; -typedef void pmpdb_readwrite_progress_t(void *instance, uint32_t size, uint32_t total); +/** + * @} + */ /** - * Structure of media record. + * @defgroup music PMPlib Music API + * @{ */ + +/** + * Structure for a music record. + */ struct tag_pmp_music_record_t { - ucs2char_t *filename; /**< Filename. */ - ucs2char_t *title; /**< Track title. */ - ucs2char_t *artist; /**< Artist name. */ - ucs2char_t *composer; /**< Composer name. */ - ucs2char_t *album; /**< Album name. */ - ucs2char_t *genre; /**< Genre name. */ - ucs2char_t *date; /**< Date. */ - uint32_t codec; /**< Codec FourCC. */ - uint32_t track_number; /**< Track number. */ - uint32_t sample_rate; /**< Sample rate in kHz. */ - uint32_t bitrate; /**< Bitrate in bps. */ - uint32_t duration; /**< Duration in seconds. */ - uint32_t filesize; /**< File size in bytes. */ - uint32_t ts_update; /**< Last update. */ - uint32_t rating; /**< Rating of the track. */ - uint32_t play_count; /**< The number of playback of the track. */ - uint32_t ts_playback; /**< Date/time of recent playback of the track. */ - uint32_t ts_import; /**< Date/time when the track was imported. */ + /** + * Relative path for the music file from the mount location of the device. + * The path character must be '\\' on all platforms (including POSIX). + * e.g., "\\Music\\Beatles\\AbbeyRoad\\01_AbbeyRoad.mp3" + * @assert @code filename != NULL @endcode + */ + ucs2char_t *filename; + + /** + * Title name. + * e.g., "Come Together" + * @assert @code title != NULL @endcode + */ + ucs2char_t *title; + + /** + * Artist name. + * e.g., "The Beatles" + * @assert @code artist != NULL @endcode + */ + ucs2char_t *artist; + + /** + * Composer. + * e.g., "John Lennon" + * @assert @code composer != NULL @endcode + */ + ucs2char_t *composer; + + /** + * Album name. + * e.g., "Abbey Road" + * @assert @code album != NULL @endcode + */ + ucs2char_t *album; + + /** + * Genre name. + * e.g., "Rock" + * @assert @code genre != NULL @endcode + */ + ucs2char_t *genre; + + /** + * Release date. + * e.g., "1969" + * @assert @code date != NULL @endcode + */ + ucs2char_t *date; + + /** + * FourCC representation of the codec. + * e.g., PMPCODEC_MPEGLAYER3 + */ + uint32_t codec; + + /** + * Track number. + * e.g., 1 + */ + uint32_t track_number; + + /** + * Sample rate in [Hz]. + * e.g., 44100 + */ + uint32_t sample_rate; + + /** + * Bitrate in [bps]. + * e.g., 128000 + */ + uint32_t bitrate; + + /** + * Duration in seconds. + * e.g., 260 + */ + uint32_t duration; + + /** + * File size in bytes. + * e.g., 4160000 + */ + uint32_t filesize; + + /** + * Timestamp of the last update of the music file. + * The value is equivalent to \c st.st_mtime after \c stat(&st, filename); + */ + uint32_t ts_update; + + /** + * Rating. + * e.g., 5 + */ + uint32_t rating; + + /** + * Play count on the device. + * e.g., 23 + */ + uint32_t play_count; + + /** + * Timestamp of the recent playback on the device. + */ + uint32_t ts_playback; + + /** + * timestamp when the track was imported. + */ + uint32_t ts_import; }; typedef struct tag_pmp_music_record_t pmp_music_record_t; @@ -461,34 +565,85 @@ result_t (*dump)(pmp_music_t* music, FILE *fp, int flag); }; +/** + * Initialize pmp_music_record_t structure. + * + * @param record The pointer to pmp_music_record_t instance. + */ +PMPAPI void pmplib_record_init(pmp_music_record_t* record); -typedef result_t (*pmp_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); +/** + * Uninitialize pmp_music_record_t structure. + * + * This function frees the memory blocks used by the \a record. + * + * @param record The pointer to pmp_music_record_t instance. + */ +PMPAPI void pmplib_record_finish(pmp_music_record_t* record); /** + * Clone a pmp_music_record_t record. + * + * This function copies the values in the \a src record to \a dst. + * + * @param dst The pointer to the destination. + * @param src The pointer to the source. + * @retval result_t The status code after this operation. + */ +PMPAPI result_t pmplib_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src); + +/** + * Uninitialize an array of pmp_music_record_t records. + * + * This function frees the memory blocks used by each record in the array and + * the array. + * + * @param record The pointer to pmp_music_record_t array. + * @param num_records The number of elements in the array. + */ +PMPAPI void pmplib_records_finish(pmp_music_record_t* records, int num_records); + +/** + * Clone a pmp_music_record_t array. + * + * This function copies all records in the \a src array to \a dst. + * + * @param dst The destination array. + * @param src The source array. + * @param num_records The number of elements in the source array. + * @retval result_t The status code after this operation. + */ +PMPAPI result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); + +PMPAPI void pmplib_playlist_init(pmp_playlist_t* playlist); +PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist); +PMPAPI void pmplib_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src); + +/** + * @} + */ + + +typedef result_t (*pmplib_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); + +/** * Prototype for the callback function for receiving device identifiers. * */ -typedef void (*pmp_enumerate_devid_callback_t)(void *instance, const char *devid); -typedef result_t (*pmp_enumerate_devid_t)(pmp_enumerate_devid_callback_t callback, void *instance); +typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid); +typedef result_t (*pmplib_enumerate_devid_t)(pmplib_enumerate_devid_callback_t callback, void *instance); -PMPAPI void pmp_record_init(pmp_music_record_t* record); -PMPAPI void pmp_record_finish(pmp_music_record_t* record); -PMPAPI result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src); -PMPAPI void pmp_records_finish(pmp_music_record_t* records, int num_records); -PMPAPI result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); +PMPAPI uint32_t pmplib_interlocked_increment(uint32_t* count); +PMPAPI uint32_t pmplib_interlocked_decrement(uint32_t* count); -PMPAPI uint32_t pmp_interlocked_increment(uint32_t* count); -PMPAPI uint32_t pmp_interlocked_decrement(uint32_t* count); -PMPAPI void pmp_playlist_init(pmp_playlist_t* playlist); -PMPAPI void pmp_playlist_finish(pmp_playlist_t* playlist); -PMPAPI void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src); /** * @defgroup pmplib PMPlib Helper API + * @{ * * The PMPlib Helper API provides the utility for choosing a suitable PMPlib * driver from a number of installed drivers. Because the PMPlib project @@ -649,7 +804,7 @@ * @code pmplib != NULL @endcode * @code callback != NULL @endcode */ -PMPAPI result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmp_enumerate_devid_callback_t callback, void *instance); +PMPAPI result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmplib_enumerate_devid_callback_t callback, void *instance); /** * @} Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-25 22:16:09 UTC (rev 277) @@ -34,13 +34,13 @@ #include <ucs2char.h> #include <pmp.h> -void pmp_record_init(pmp_music_record_t* record) +void pmplib_record_init(pmp_music_record_t* record) { memset(record, 0, sizeof(*record)); } -void pmp_record_finish(pmp_music_record_t* record) +void pmplib_record_finish(pmp_music_record_t* record) { ucs2free(record->filename); ucs2free(record->title); @@ -48,10 +48,10 @@ ucs2free(record->album); ucs2free(record->genre); ucs2free(record->date); - pmp_record_init(record); + pmplib_record_init(record); } -result_t pmp_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src) +result_t pmplib_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src) { memcpy(dst, src, sizeof(*src)); dst->filename = src->filename ? ucs2dup(src->filename) : NULL; @@ -63,29 +63,29 @@ return 0; } -void pmp_records_finish(pmp_music_record_t* records, int num_records) +void pmplib_records_finish(pmp_music_record_t* records, int num_records) { int i; for (i = 0;i < num_records;++i) { - pmp_record_finish(&records[i]); + pmplib_record_finish(&records[i]); } ucs2free(records); } -result_t pmp_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records) +result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records) { int i; for (i = 0;i < num_records;++i) { - pmp_record_clone(&dst[i], &src[i]); + pmplib_record_clone(&dst[i], &src[i]); } } -void pmp_playlist_init(pmp_playlist_t* playlist) +void pmplib_playlist_init(pmp_playlist_t* playlist) { memset(playlist, 0, sizeof(*playlist)); } -void pmp_playlist_finish(pmp_playlist_t* playlist) +void pmplib_playlist_finish(pmp_playlist_t* playlist) { int i; for (i = 0;i < playlist->num_entries;++i) { @@ -95,7 +95,7 @@ ucs2free(playlist->name); } -void pmp_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src) +void pmplib_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src) { int i; Modified: trunk/pmplib/lib/pmp/pmp_win32.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_win32.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp/pmp_win32.c 2007-01-25 22:16:09 UTC (rev 277) @@ -40,12 +40,12 @@ }; -uint32_t pmp_interlocked_increment(uint32_t* count) +uint32_t pmplib_interlocked_increment(uint32_t* count) { return (uint32_t)InterlockedIncrement((LONG*)count); } -uint32_t pmp_interlocked_decrement(uint32_t* count) +uint32_t pmplib_interlocked_decrement(uint32_t* count) { return (uint32_t)InterlockedDecrement((LONG*)count); } @@ -101,11 +101,11 @@ return 0; } -result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmp_enumerate_devid_callback_t callback, void *instance) +result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmplib_enumerate_devid_callback_t callback, void *instance) { uint32_t i; for (i = 0;i < pmplib->num_plugins;++i) { - pmp_enumerate_devid_t func = (pmp_enumerate_devid_t)GetProcAddress(pmplib->plugins[i], "pmp_enumerate_devid"); + pmplib_enumerate_devid_t func = (pmplib_enumerate_devid_t)GetProcAddress(pmplib->plugins[i], "pmp_enumerate_devid"); if (func) { func(callback, instance); } @@ -119,7 +119,7 @@ result_t ret = PMP_DEVICENOTFOUND; for (i = 0;i < pmplib->num_plugins;++i) { - pmp_create_t func = (pmp_create_t)GetProcAddress(pmplib->plugins[i], "pmp_create"); + pmplib_create_t func = (pmplib_create_t)GetProcAddress(pmplib->plugins[i], "pmp_create"); if (func) { ret = func(pmp, path_to_device, id); if (ret != PMP_DEVICENOTFOUND) { Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-01-25 22:16:09 UTC (rev 277) @@ -264,7 +264,7 @@ ip2db_record_t src; pmp_music_record_t* dst = &records[j]; - pmp_record_init(dst); + pmplib_record_init(dst); ip2db_get_record(db, i, &src); Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-25 22:16:09 UTC (rev 277) @@ -282,7 +282,7 @@ -PMPIRIVERPLUS2API result_t pmp_enumerate_devid(pmp_enumerate_devid_callback_t callback, void *instance) +PMPIRIVERPLUS2API result_t pmp_enumerate_devid(pmplib_enumerate_devid_callback_t callback, void *instance) { const ip2model_descriptor_t* md = g_model_descriptions; for (;md->id;++md) { @@ -378,12 +378,12 @@ static uint32_t pmp_add_ref(pmp_t* pmp) { - return pmp_interlocked_increment(&pmp->ref_count); + return pmplib_interlocked_increment(&pmp->ref_count); } static uint32_t pmp_release(pmp_t* pmp) { - uint32_t count = pmp_interlocked_decrement(&pmp->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmp->ref_count); if (count == 0) { pmpdb_release(pmp->music); free(pmp->instance); @@ -552,12 +552,12 @@ static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) { - return pmp_interlocked_increment(&pmppl->ref_count); + return pmplib_interlocked_increment(&pmppl->ref_count); } static uint32_t pmppl_release(pmp_playlist_t* pmppl) { - uint32_t count = pmp_interlocked_decrement(&pmppl->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); if (count == 0) { pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; free(pmppl->instance); Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-25 22:16:09 UTC (rev 277) @@ -304,7 +304,7 @@ -PMPIRIVERPLUS3API result_t pmp_enumerate_devid(pmp_enumerate_devid_callback_t callback, void *instance) +PMPIRIVERPLUS3API result_t pmp_enumerate_devid(pmplib_enumerate_devid_callback_t callback, void *instance) { const ip3model_descriptor_t* md = g_model_descriptions; for (;md->id;++md) { @@ -388,12 +388,12 @@ static uint32_t pmp_add_ref(pmp_t* pmp) { - return pmp_interlocked_increment(&pmp->ref_count); + return pmplib_interlocked_increment(&pmp->ref_count); } static uint32_t pmp_release(pmp_t* pmp) { - uint32_t count = pmp_interlocked_decrement(&pmp->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmp->ref_count); if (count == 0) { pmpmusic_release(pmp->music); free_device_info(&pmp->info); @@ -470,7 +470,7 @@ { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; ip3db_finish(&pmpmi->ip3db); - pmp_records_finish(pmpmi->records, pmpmi->num_records); + pmplib_records_finish(pmpmi->records, pmpmi->num_records); free(pmpmi->playlists); free(pmpmi); free(music); @@ -484,7 +484,7 @@ pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; // Free the existing records. - pmp_records_finish(pmpmi->records, pmpmi->num_records); + pmplib_records_finish(pmpmi->records, pmpmi->num_records); pmpmi->records = 0; pmpmi->num_records = 0; @@ -513,7 +513,7 @@ pmp_music_record_t* dst = &pmpmi->records[i]; size_t length = 0; - pmp_record_init(dst); + pmplib_record_init(dst); length = ucs2len(pmp->info.path_to_root); length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str); @@ -636,12 +636,12 @@ pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; /* Free records attached to pmpmi. */ - pmp_records_finish(pmpmi->records, pmpmi->num_records); + pmplib_records_finish(pmpmi->records, pmpmi->num_records); /* Allocate new records. */ pmpmi->records = (pmp_music_record_t*)ucs2malloc(sizeof(pmp_music_record_t) * num_records); pmpmi->num_records = num_records; - pmp_records_clone(pmpmi->records, records, num_records); + pmplib_records_clone(pmpmi->records, records, num_records); return 0; } @@ -655,7 +655,7 @@ *num_records = pmpmi->num_records; return 0; } else if (*num_records == pmpmi->num_records) { - pmp_records_clone(records, pmpmi->records, pmpmi->num_records); + pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { return PMPDBE_INSUFFICIENT; Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-25 22:16:09 UTC (rev 277) @@ -115,7 +115,7 @@ return filepath_file_exists(filename); } -PMPIRIVNAVIAPI result_t pmp_enumerate_devid(pmp_enumerate_devid_callback_t callback, void *instance) +PMPIRIVNAVIAPI result_t pmp_enumerate_devid(pmplib_enumerate_devid_callback_t callback, void *instance) { callback(instance, MODELID_H100); callback(instance, MODELID_H300); @@ -237,12 +237,12 @@ static uint32_t pmp_add_ref(pmp_t* pmp) { - return pmp_interlocked_increment(&pmp->ref_count); + return pmplib_interlocked_increment(&pmp->ref_count); } static uint32_t pmp_release(pmp_t* pmp) { - uint32_t count = pmp_interlocked_decrement(&pmp->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmp->ref_count); if (count == 0) { pmpdb_release(pmp->music); free(pmp); @@ -526,7 +526,7 @@ const record_t* src = &db->records[i]; pmp_music_record_t* dst = &records[j]; - pmp_record_init(dst); + pmplib_record_init(dst); tmp = mbsdupucs2(src->filename); length = ucs2len(path_to_root); @@ -600,12 +600,12 @@ static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) { - return pmp_interlocked_increment(&pmppl->ref_count); + return pmplib_interlocked_increment(&pmppl->ref_count); } static uint32_t pmppl_release(pmp_playlist_t* pmppl) { - uint32_t count = pmp_interlocked_decrement(&pmppl->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); if (count == 0) { free(pmppl); } Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-25 22:16:09 UTC (rev 277) @@ -345,7 +345,7 @@ -PMPPORTALPLAYER1API result_t pmp_enumerate_devid(pmp_enumerate_devid_callback_t callback, void *instance) +PMPPORTALPLAYER1API result_t pmp_enumerate_devid(pmplib_enumerate_devid_callback_t callback, void *instance) { const pp1model_descriptor_t* md = g_model_descriptions; for (;md->id;++md) { @@ -444,12 +444,12 @@ static uint32_t pmp_add_ref(pmp_t* pmp) { - return pmp_interlocked_increment(&pmp->ref_count); + return pmplib_interlocked_increment(&pmp->ref_count); } static uint32_t pmp_release(pmp_t* pmp) { - uint32_t count = pmp_interlocked_decrement(&pmp->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmp->ref_count); if (count == 0) { pmpdb_release(pmp->music); free(pmp->instance); @@ -600,12 +600,12 @@ static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) { - return pmp_interlocked_increment(&pmppl->ref_count); + return pmplib_interlocked_increment(&pmppl->ref_count); } static uint32_t pmppl_release(pmp_playlist_t* pmppl) { - uint32_t count = pmp_interlocked_decrement(&pmppl->ref_count); + uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); if (count == 0) { free(pmppl); } Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-01-25 03:06:49 UTC (rev 276) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-01-25 22:16:09 UTC (rev 277) @@ -560,7 +560,7 @@ const dat_t* src = &db->dat[i]; pmp_music_record_t* dst = &records[j]; - pmp_record_init(dst); + pmplib_record_init(dst); db->hdr->param.proc_dat_get(dst, src, path_to_root); ++j; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 00:37:56
|
Revision: 278 http://svn.sourceforge.net/pmplib/?rev=278&view=rev Author: nyaochi Date: 2007-01-25 16:37:56 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Updated EasyPMP CUI progress reports. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/common/easypmp.h trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/frontend/easypmp/cui/option.h trunk/pmplib/pmp.sln Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-01-26 00:37:56 UTC (rev 278) @@ -39,11 +39,6 @@ #include <gmi.h> #include <easypmp.h> -/** - * \addtogroup common - * @{ - */ - #ifdef _WIN32 #define COMP_STR(x, y) lstrcmpiW(x, y) /* FAT32 treats upper/lower letters as identical. */ #else @@ -99,8 +94,8 @@ int easypmp_database( - const easypmp_filelist_t* fl, pmp_t* pmp, + const easypmp_filelist_t* fl, const option_t* opt, pmp_music_record_t** ptr_records, uint32_t* ptr_num_records, @@ -118,25 +113,12 @@ uint32_t num_old_records = 0, num_obtained = 0; uint32_t ts_import = get_current_time(); - if (progress(instance, EASYPMPDBP_START, 0, 0, NULL) != 0) { - return EASYPMPE_CANCEL; - } - filepath_combinepath(music_path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); /* * Read the existing database for update processing mode. */ if (opt->verb & MODE_DATABASE_UPDATE) { - /* - * Read the existing database for update processing mode. - */ - // Start reading a database. - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - // Obtain the number of records in the database. res = pmpdb->get_records(pmpdb, NULL, &num_old_records); if (res != 0) { @@ -160,11 +142,6 @@ // Sort the records for binary search. qsort(old_records, num_old_records, sizeof(pmp_music_record_t), comp_filename); - } else { - if (progress(instance, EASYPMPDBP_READ | EASYPMPSP_SKIPPED, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } } /* @@ -179,7 +156,7 @@ /* * Obtain music information. */ - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_START, fl->num_elements, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_START, fl->num_elements, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -195,7 +172,7 @@ timestamp = (uint32_t)ucs2stat_mtime(filename); // Report the progress. - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -235,40 +212,21 @@ record->ts_import = ts_import; } } - if (progress(instance, EASYPMPDBP_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - // Generate database. - if (progress(instance, EASYPMPDBP_UPDATE | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } res = pmpdb->set_records(pmpdb, records, fl->num_elements); if (res != 0) { result = MAKE_PMP_ERROR(res); goto error_exit; } - if (progress(instance, EASYPMPDBP_UPDATE | EASYPMPSP_END, 0, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_MUSIC_UPDATE | EASYPMPSP_END, 0, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - if (progress(instance, EASYPMPDBP_WRITE | EASYPMPSP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - if (progress(instance, EASYPMPDBP_WRITE | EASYPMPSP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - - if (progress(instance, EASYPMPDBP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - error_exit: /* * Free allocated memory. @@ -364,5 +322,3 @@ } return 0; } - -/** @} */ Modified: trunk/pmplib/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-26 00:37:56 UTC (rev 278) @@ -36,17 +36,14 @@ */ enum { - EASYPMPDBP_START = 0x00010000, - EASYPMPDBP_READ = 0x00020000, - EASYPMPDBP_GMI = 0x00030000, - EASYPMPDBP_UPDATE = 0x00040000, - EASYPMPDBP_WRITE = 0x00050000, - EASYPMPDBP_END = 0x00060000, + EASYPMPP_START = 0x00010000, + EASYPMPP_OPEN = 0x00020000, + EASYPMPP_MUSIC_GMI = 0x00030000, + EASYPMPP_MUSIC_UPDATE = 0x00040000, + EASYPMPP_PLAYLIST_CONVERT = 0x02050000, + EASYPMPP_CLOSE = 0x00060000, + EASYPMPP_END = 0x00070000, - EASYPMPPLP_START = 0x01000000, - EASYPMPPLP_CONVERT = 0x02000000, - EASYPMPPLP_END = 0x03000000, - EASYPMPSP_START = 0x00000001, EASYPMPSP_PROGRESS = 0x00000002, EASYPMPSP_SKIPPED = 0x00000003, @@ -141,8 +138,8 @@ int easypmp_database( - const easypmp_filelist_t* fl, pmp_t* pmp, + const easypmp_filelist_t* fl, const option_t* opt, pmp_music_record_t** ptr_records, uint32_t* ptr_num_records, Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-26 00:37:56 UTC (rev 278) @@ -48,7 +48,7 @@ static void callback_from_playlist(void *instance, int level, ucs2char_t* message) { - int phase = EASYPMPPLP_CONVERT; + int phase = EASYPMPP_PLAYLIST_CONVERT; callback_data_t* cd = (callback_data_t*)instance; switch (level) { @@ -93,12 +93,6 @@ filepath_combinepath(dstpath, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); - // Start playlist processing. - if (progress(instance, EASYPMPPLP_START, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - // Convert easypmp_filelist_t array to playlist_mediafile_t array. mediafiles = calloc(musics->num_elements, sizeof(playlist_mediafile_t)); if (musics->num_elements > 0 && !mediafiles) { @@ -114,7 +108,7 @@ playlist_normalize_prepare(mediafiles, musics->num_elements); // Start playlist conversion. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_START, playlists->num_elements, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_START, playlists->num_elements, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -134,7 +128,7 @@ filepath_combinepath(src, MAX_PATH, plf_path, plf->filename); // Report the source filename. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_PROGRESS, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_PROGRESS, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -175,7 +169,7 @@ // Skip an empty playlist. if (pl->num_entries == 0) { - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -193,13 +187,13 @@ if (n < pl->num_entries) { if ((opt->verb & MODE_PLAYLIST_SKIP) && 0 < n) { // Report a warning. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_WARN_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_WARN_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } } else { // Report a error (skipping). - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -208,7 +202,7 @@ // Report missing media files. for (j = 0;j < pl->num_entries;++j) { if (!pl->entries[j].valid) { - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_MISSING_MEDIA, i, 0, pl->entries[j].filename) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_MISSING_MEDIA, i, 0, pl->entries[j].filename) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -248,17 +242,11 @@ music->set_playlists(music, pmppls, num_pmppls); // Finish playlist conversion. - if (progress(instance, EASYPMPPLP_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { + if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_END, num_succeeded, 0, NULL) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } - // Finish the whole processing. - if (progress(instance, EASYPMPPLP_END, 0, 0, NULL) != 0) { - result = EASYPMPE_CANCEL; - goto error_exit; - } - error_exit: for (i = 0;i < num_pmppls;++i) { pmplib_playlist_finish(&pmppls[i]); Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-26 00:37:56 UTC (rev 278) @@ -74,18 +74,18 @@ static void enumerate_devid_callback(void *instance, const char *devid) { - pmplib_t *pmphelp = (pmplib_t*)instance; + pmplib_t *pmplib = (pmplib_t*)instance; pmp_t* pmp = NULL; ucs2char_t ucs2cs_empty[] = {0}; - pmplib_create(pmphelp, &pmp, ucs2cs_empty, devid); + pmplib_create(pmplib, &pmp, ucs2cs_empty, devid); device_show_information(pmp, stdout); fprintf(stderr, "\n"); pmp->release(pmp); } -void device_enumerate(pmplib_t* pmphelp) +void device_enumerate(pmplib_t* pmplib) { - pmplib_enumerate_devid(pmphelp, enumerate_devid_callback, pmphelp); + pmplib_enumerate_devid(pmplib, enumerate_devid_callback, pmplib); } /** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 00:37:56 UTC (rev 278) @@ -51,18 +51,13 @@ #include <windows.h> #endif -/** - * \addtogroup cui - * @{ - */ - #define APPLICATION_S "EasyPMP [CUI]" #define VERSION_S "0.13 alpha" #define COPYRIGHT_S "Copyright (c) 2005-2007 Nyaochi" int database_dump(pmp_t* pmp, FILE *fpo, int level); void device_show_information(pmp_t* pmp, FILE *fpe); -void device_enumerate(pmplib_t* pmphelp); +void device_enumerate(pmplib_t* pmplib); int easypmp_progress_num_str( @@ -96,81 +91,76 @@ FILE *fpe = stderr; switch (phase) { - case EASYPMPDBP_START: + case EASYPMPP_START: break; - case EASYPMPDBP_READ|EASYPMPSP_START: - fprintf(fpo, "Reading database\n"); + case EASYPMPP_OPEN|EASYPMPSP_START: + fprintf(fpo, "Opening the device\n"); break; - case EASYPMPDBP_READ|EASYPMPSP_PROGRESS: + case EASYPMPP_OPEN|EASYPMPSP_END: + fprintf(fpo, "\n"); break; - case EASYPMPDBP_READ|EASYPMPSP_END: + case EASYPMPP_CLOSE|EASYPMPSP_START: + fprintf(fpo, "Closing the device\n"); + break; + case EASYPMPP_CLOSE|EASYPMPSP_END: fprintf(fpo, "\n"); break; - case EASYPMPDBP_GMI|EASYPMPSP_START: + case EASYPMPP_END: + break; + + case EASYPMPP_MUSIC_GMI|EASYPMPSP_START: fprintf(fpo, "Obtaining media information from %d files\n", param_int); break; - case EASYPMPDBP_GMI|EASYPMPSP_PROGRESS: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_PROGRESS: easypmp_progress_num_str(fpo, param_int+1, filepath_skippath(param_str)); break; - case EASYPMPDBP_GMI|EASYPMPSP_END: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: console_clearln(fpo); fprintf(fpo, " %d files were imported\n", param_int); fprintf(fpo, "\n"); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_START: - fprintf(fpo, "Updating database\n"); + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_START: + fprintf(fpo, "Updating database entries\n"); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_END: + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_END: fprintf(fpo, "\n"); break; - case EASYPMPDBP_WRITE|EASYPMPSP_START: - fprintf(fpo, "Writing database\n"); - break; - case EASYPMPDBP_WRITE|EASYPMPSP_PROGRESS: - break; - case EASYPMPDBP_WRITE|EASYPMPSP_END: - fprintf(fpo, "\n"); - break; - case EASYPMPDBP_END: - break; - case EASYPMPPLP_START: - break; - case EASYPMPPLP_CONVERT|EASYPMPSP_START: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_START: fprintf(fpo, "Converting playlists\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_PROGRESS: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_PROGRESS: easypmp_progress_num_str(fpo, param_int+1, filepath_skippath(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_WARN_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_WARN_PLAYLIST: fprintf(fpe, "\n"); fprintf(fpe, " WARNING: following media files are missing:\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_SKIP_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_SKIP_PLAYLIST: fprintf(fpe, "\n"); fprintf(fpe, " ERROR: following media files are missing:\n"); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_MISSING_MEDIA: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_MISSING_MEDIA: fprints(fpe, " %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR: fprintf(fpe, "\n"); fprints(fpe, " JSPL(ERROR): %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_POS: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR_POS: fprints(fpe, " at: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: fprints(fpe, " line: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_OUTPUT: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_OUTPUT: fprints(fpo, " JSPL: %s\n", param_str); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_END: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_END: + console_clearln(fpo); + fprintf(fpo, " %d files were successfully converted\n", param_int); fprintf(fpo, "\n"); break; - case EASYPMPPLP_END: - break; } fflush(fpe); @@ -204,10 +194,11 @@ int main(int argc, char *argv[]) { int ret = 0; + result_t res = 0; int used_args = 0; char *mbs = NULL; - pmplib_t* pmphelp = NULL; pmp_t* pmp = NULL; + pmplib_t* pmplib = NULL; easypmp_filelist_t musics, playlists; pmp_music_record_t* records = NULL; uint32_t num_records = 0; @@ -215,7 +206,9 @@ FILE *fpi = stdin, *fpo = stdout, *fpe = stderr; option_t opt; + // Initialize various routines. setlocale(LC_ALL, ""); + console_init(); // Initialize option values. option_init(&opt); @@ -240,7 +233,7 @@ } #endif/*_WIN32*/ - /* Set words to be stripped from artist names. */ + // Set words to be stripped from artist names. if (opt.mbs_strip_words) { ucs2char_t* ucs2str = mbsdupucs2(opt.mbs_strip_words); easypmp_set_strip_words(&opt, ucs2str); @@ -248,7 +241,7 @@ opt.media_info_source |= GMIF_STRIP_ARTIST; } - /* Obtain the path to root directory (path_to_root) from the command line if any. */ + // Obtain the path to root directory (path_to_root) from the command line if any. if (used_args < argc) { size_t length = strlen(argv[used_args]); if (length > 0) { @@ -270,12 +263,16 @@ goto exit_main; } - // Initialize PMP helper library. - pmplib_init(&pmphelp); + // Initialize PMPlib library. + if (res = pmplib_init(&pmplib)) { + fprintf(fpe, "ERROR: Failed to initialize PMPlib library (%d)\n", res); + ret = 1; + goto exit_main; + } // Show the list of supported devices and exit. if (opt.verb & MODE_LIST_DEVICES) { - device_enumerate(pmphelp); + device_enumerate(pmplib); ret = 0; goto exit_main; } @@ -286,17 +283,6 @@ char pwd[MAX_PATH+1]; getcwd(pwd, MAX_PATH); mbstoucs2(opt.path_to_root, MAX_PATH, pwd, strlen(pwd)+1); - } else if (opt.path_to_root[0] == '-' && opt.path_to_root[1] == 0) { -#ifdef _WIN32 - // (Win32 only) - // If path_to_root is "-", assume the root folder of the path where this executable is located. - ucs2char_t* p = NULL; - GetModuleFileNameW(GetModuleHandle(NULL), opt.path_to_root, MAX_PATH); - p = (ucs2char_t*)filepath_skip_one_directory(opt.path_to_root); - if (p) { - *p = 0; - } -#endif } filepath_addslash(opt.path_to_root); @@ -318,38 +304,50 @@ } // Create a PMP instance. - ret = pmplib_create(pmphelp, &pmp, opt.path_to_root, opt.model); + res = pmplib_create(pmplib, &pmp, opt.path_to_root, opt.model); if (!pmp) { - fprintf(fpe, "Failed to find a player (%d)\n", ret); + fprintf(fpe, "ERROR: Failed to find a player (%d)\n", res); ret = 1; goto exit_main; } - // Open flag. + // Generate open flag. if (opt.verb & MODE_DATABASE) { + openflag |= PMPOF_MUSIC_DB_WRITE; if (opt.verb & MODE_DATABASE_UPDATE) { openflag |= PMPOF_MUSIC_DB_READ; } - openflag |= PMPOF_MUSIC_DB_WRITE; } if (opt.verb & MODE_DATABASE_REPR) { openflag |= PMPOF_MUSIC_DB_READ; } - if (opt.verb & MODE_PLAYLIST) { openflag |= PMPOF_MUSIC_PL_WRITE; } - // Open the PMP. - ret = pmp->open(pmp, openflag); + // Open the portable media device. + if (easypmp_progress(NULL, EASYPMPP_OPEN | EASYPMPSP_START, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + res = pmp->open(pmp, openflag); + if (res) { + fprintf(fpe, "ERROR: Failed to open the player (%d)\n", res); + ret = 1; + goto exit_main; + } + if (easypmp_progress(NULL, EASYPMPP_OPEN | EASYPMPSP_END, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } // Show player information. device_show_information(pmp, fpo); fprintf(fpo, "\n"); + // Enumerate music files for database and playlist modes. memset(&musics, 0, sizeof(musics)); - console_init(); - if ((opt.verb & MODE_DATABASE) || ((opt.verb & MODE_PLAYLIST) && (opt.verb & MODE_PLAYLIST_FIND))) { + if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST)) { fprintf(fpo, "Enumerating music files\n"); easypmp_enumerate_music(&musics, pmp, &opt, easypmp_enumerate_progress, NULL); console_clearln(fpo); @@ -357,6 +355,7 @@ fprintf(fpo, "\n"); } + // Enumerate playlist files for playlist mode. memset(&playlists, 0, sizeof(playlists)); if (opt.verb & MODE_PLAYLIST) { fprintf(fpe, "Enumerating playlist files\n"); @@ -366,17 +365,13 @@ fprintf(fpo, "\n"); } - // Execute jobs. - if (opt.verb & MODE_DATABASE) { - easypmp_database(&musics, pmp, &opt, &records, &num_records, easypmp_progress, NULL); + // Update database entries for database mode and JSPL playlists. + if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST_JSPL)) { + easypmp_database(pmp, &musics, &opt, &records, &num_records, easypmp_progress, NULL); } + + // Convert playlists. if (opt.verb & MODE_PLAYLIST) { - /* - // Read the database for JSPL. - if ((opt.verb & MODE_PLAYLIST_JSPL) && (!records)) { - easypmp_database_read(pmp, &opt, &records, &num_records, easypmp_progress, NULL); - } - */ #ifndef HAVE_JSAPI_H if(opt.verb & MODE_PLAYLIST_JSPL) { fprintf(fpe, "Warning: Ignoring -j/--jspl option. This version of easypmp\n"); @@ -385,22 +380,36 @@ #endif easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, NULL); } + + // Dump the database if specified. if (opt.verb & MODE_DATABASE_REPR) { database_dump(pmp, fpo, opt.repr_level); } - if (records) { - /* Free the record array. */ - int i; - for (i = 0;i < num_records;++i) { - pmplib_record_finish(&records[i]); - } - free(records); + // Free the music records. + if (records && num_records) { + pmplib_records_finish(records, num_records); } - pmp->close(pmp); + // Close the portable media device. + if (easypmp_progress(NULL, EASYPMPP_CLOSE | EASYPMPSP_START, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + res = pmp->close(pmp); + if (res) { + fprintf(fpe, "ERROR: Failed to close the player (%d)\n", res); + ret = 1; + goto exit_main; + } + if (easypmp_progress(NULL, EASYPMPP_CLOSE | EASYPMPSP_END, 0, 0, NULL) != 0) { + ret = 1; + goto exit_main; + } + + // Uninitialize. pmp->release(pmp); - pmplib_finish(pmphelp); + pmplib_finish(pmplib); option_finish(&opt); return ret; @@ -410,11 +419,10 @@ pmp->release(pmp); pmp = NULL; } - if (pmphelp) { - pmplib_finish(pmphelp); - pmphelp = NULL; + if (pmplib) { + pmplib_finish(pmplib); + pmplib = NULL; } option_finish(&opt); return ret; } -/** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 00:37:56 UTC (rev 278) @@ -83,10 +83,9 @@ fprintf(fp, "\n"); fprintf(fp, "Playlist options:\n"); fprintf(fp, " -p, --playlist Convert playlist files in PLAYLIST directory\n"); - fprintf(fp, " -m, --music Convert playlist files in MUSIC directory\n"); fprintf(fp, " -r, --reconvert Discard the existing playlist files and reconvert\n"); fprintf(fp, " -f, --find-missing Correct playlists with corrupt references to media files\n"); - fprintf(fp, " -s, --skip-missing Continue a conversion even if a media file is missing\n"); + fprintf(fp, " -i, --ignore-missing Continue a conversion even if a media file is missing\n"); #ifdef HAVE_JSAPI_H fprintf(fp, " -j, --jspl Enable JavaScript playlist (JSPL)\n"); #endif @@ -94,6 +93,8 @@ fprintf(fp, "Player options:\n"); fprintf(fp, " -l, --list-device Show the list of supported devices and exit\n"); fprintf(fp, " -d, --device Specify a device identifier for the player\n"); + fprintf(fp, " -s, --set=NAME=VALUE Set a variable NAME to VALUE\n"); + fprintf(fp, " -V, --show-variables Show list of variables and their default values\n"); fprintf(fp, "\n"); #ifndef _WIN32 fprintf(fp, "Language-specific options:\n"); @@ -161,13 +162,14 @@ {"repr-level", required_argument, 0, 'L'}, {"strip-words", required_argument, 0, 't'}, {"playlist", no_argument, 0, 'p'}, - {"music", no_argument, 0, 'm'}, {"reconvert", no_argument, 0, 'r'}, {"find-missing", no_argument, 0, 'f'}, - {"skip-missing", no_argument, 0, 's'}, + {"ignore-missing", no_argument, 0, 's'}, {"jspl", no_argument, 0, 'j'}, {"list-device", no_argument, 0, 'l'}, {"device", required_argument, 0, 'd'}, + {"set", required_argument, 0, 's'}, + {"show-variables", no_argument, 0, 'V'}, #ifndef _WIN32 {"encoding", required_argument, 0, 'e'}, {"tagencoding", required_argument, 0, 'w'}, @@ -222,16 +224,13 @@ case 'p': opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_PLAYLIST); break; - case 'm': - opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_MUSIC); - break; case 'r': opt->verb |= MODE_PLAYLIST_RECONVERT; break; case 'f': opt->verb |= MODE_PLAYLIST_FIND; break; - case 's': + case 'i': opt->verb |= MODE_PLAYLIST_SKIP; break; case 'j': @@ -243,6 +242,10 @@ case 'd': strcpy(opt->model, optarg); break; + case 's': + break; + case 'V': + break; #ifndef _WIN32 case 'e': free(opt->system_encoding); Modified: trunk/pmplib/frontend/easypmp/cui/option.h =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.h 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/frontend/easypmp/cui/option.h 2007-01-26 00:37:56 UTC (rev 278) @@ -25,16 +25,9 @@ #ifndef __OPTION_H__ #define __OPTION_H__ -/** - * \addtogroup cui - * @{ - */ - void option_init(option_t* opt); void option_finish(option_t* opt); int option_parse(option_t* opt, int argc, char *argv[], FILE *fpe); void option_usage(FILE *fp, const char *argv0); -/** @} */ - #endif/*__OPTION_H__*/ Modified: trunk/pmplib/pmp.sln =================================================================== --- trunk/pmplib/pmp.sln 2007-01-25 22:16:09 UTC (rev 277) +++ trunk/pmplib/pmp.sln 2007-01-26 00:37:56 UTC (rev 278) @@ -44,11 +44,8 @@ ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} - {544769C2-6989-452F-B626-E442CAC6553B} = {544769C2-6989-452F-B626-E442CAC6553B} {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} - {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject @@ -72,9 +69,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_iriverplus3", "lib\pmp_iriverplus3\pmp_iriverplus3.vcproj", "{C74FE9C9-B5C4-438A-B157-9BCB6C8A7546}" ProjectSection(ProjectDependencies) = postProject - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} + {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} + {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Global This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 01:12:09
|
Revision: 279 http://svn.sourceforge.net/pmplib/?rev=279&view=rev Author: nyaochi Date: 2007-01-25 17:12:08 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Synchronize the CUI frontend with the latest playlist API. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/easypmp.h trunk/pmplib/frontend/easypmp/common/enumerate.c trunk/pmplib/frontend/easypmp/common/playlist.c trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-01-26 01:12:08 UTC (rev 279) @@ -73,8 +73,6 @@ MODE_DATABASE_UPDATE = 0x00000002, MODE_DATABASE_REPR = 0x00000004, MODE_PLAYLIST = 0x00000010, - MODE_PLAYLIST_PLAYLIST = 0x00000020, - MODE_PLAYLIST_MUSIC = 0x00000040, MODE_PLAYLIST_RECONVERT = 0x00000100, MODE_PLAYLIST_FIND = 0x00000200, MODE_PLAYLIST_SKIP = 0x00000400, @@ -155,9 +153,9 @@ int easypmp_playlist( + pmp_t* pmp, const easypmp_filelist_t* playlists, const easypmp_filelist_t* musics, - pmp_t* pmp, const option_t* opt, pmp_music_record_t* records, uint32_t num_records, Modified: trunk/pmplib/frontend/easypmp/common/enumerate.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-01-26 01:12:08 UTC (rev 279) @@ -186,28 +186,15 @@ ed.proc = proc; ed.instance = instance; - if (opt->verb & MODE_PLAYLIST_PLAYLIST) { - // Decode the playlist path prefix for system path separators - filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); - filepath_decode(path); - ret = find_file( - path, - pmp->info.playlist_flag & PMPPF_RECURSIVE ? 1 : 0, - found_playlist_file, - &ed - ); - } - if (opt->verb & MODE_PLAYLIST_MUSIC) { - // Decode the playlist path prefix for system path separators - filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); - filepath_decode(path); - ret = find_file( - path, - pmp->info.music_flag & PMPMF_RECURSIVE ? 1 : 0, - found_playlist_file, - &ed - ); - } + // Decode the playlist path prefix for system path separators + filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); + filepath_decode(path); + ret = find_file( + path, + pmp->info.playlist_flag & PMPPF_RECURSIVE ? 1 : 0, + found_playlist_file, + &ed + ); return ret; } Modified: trunk/pmplib/frontend/easypmp/common/playlist.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/frontend/easypmp/common/playlist.c 2007-01-26 01:12:08 UTC (rev 279) @@ -36,11 +36,6 @@ #include <easypmp.h> -/** - * \addtogroup common - * @{ - */ - typedef struct { void *instance; easypmp_progress_t progress; @@ -64,9 +59,9 @@ int easypmp_playlist( + pmp_t* pmp, const easypmp_filelist_t* playlists, const easypmp_filelist_t* musics, - pmp_t* pmp, const option_t* opt, pmp_music_record_t* records, uint32_t num_records, @@ -83,7 +78,6 @@ int num_pmppls = 0; result_t res = 0; callback_data_t cd; - ucs2char_t dstpath[MAX_PATH]; cd.instance = instance; cd.progress = progress; @@ -91,8 +85,6 @@ // Query the interface to music. music = pmp->music; - filepath_combinepath(dstpath, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); - // Convert easypmp_filelist_t array to playlist_mediafile_t array. mediafiles = calloc(musics->num_elements, sizeof(playlist_mediafile_t)); if (musics->num_elements > 0 && !mediafiles) { @@ -157,16 +149,9 @@ pmp_playlist_t* pmppl = NULL; // Generate a destination filename. - filepath_combinepath(dst, MAX_PATH, dstpath, filepath_skippath(pl->name)); + ucs2cpy(dst, filepath_skippath(pl->name)); filepath_remove_extension(dst); - // Skipping the existing playlist - if (!(opt->verb & MODE_PLAYLIST_RECONVERT)) { - if (filepath_file_exists(dst) && filepath_compare_lastupdate(src, dst) <= 0) { - continue; - } - } - // Skip an empty playlist. if (pl->num_entries == 0) { if (progress(instance, EASYPMPP_PLAYLIST_CONVERT | EASYPMPSP_SKIP_PLAYLIST, i, 0, src) != 0) { @@ -227,6 +212,8 @@ result = EASYPMPE_INSUFFICIENT_MEMORY; goto error_exit; } + + // Store the playlist. for (j = 0, n = 0;j < pl->num_entries;++j) { if (pl->entries[j].valid && pl->entries[j].filename[0]) { pmppl->entries[n] = ucs2dup(pl->entries[j].filename); @@ -239,6 +226,7 @@ } } + // Set playlists. music->set_playlists(music, pmppls, num_pmppls); // Finish playlist conversion. @@ -255,5 +243,3 @@ free(mediafiles); return result; } -/** @} */ - Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 01:12:08 UTC (rev 279) @@ -378,7 +378,7 @@ fprintf(fpe, " was built without support for JavaScript playlists.\n"); } #endif - easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, NULL); + easypmp_playlist(pmp, &playlists, &musics, &opt, records, num_records, easypmp_progress, NULL); } // Dump the database if specified. Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 01:12:08 UTC (rev 279) @@ -222,7 +222,7 @@ opt->mbs_strip_words = strdup(optarg); break; case 'p': - opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_PLAYLIST); + opt->verb |= MODE_PLAYLIST; break; case 'r': opt->verb |= MODE_PLAYLIST_RECONVERT; Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/include/pmp.h 2007-01-26 01:12:08 UTC (rev 279) @@ -617,7 +617,7 @@ PMPAPI void pmplib_playlist_init(pmp_playlist_t* playlist); PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist); -PMPAPI void pmplib_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src); +PMPAPI void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src); /** * @} Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-26 01:12:08 UTC (rev 279) @@ -95,7 +95,7 @@ ucs2free(playlist->name); } -void pmplib_playlist_copy(pmp_playlist_t* dst, const pmp_playlist_t* src) +void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src) { int i; Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-26 00:37:56 UTC (rev 278) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-26 01:12:08 UTC (rev 279) @@ -676,6 +676,7 @@ static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists) { uint32_t i, j; + static const ucs2char_t rootdir[] = {PATHCHAR,0}; static const ucs2char_t plp_ext[] = {'.','p','l','p',0}; pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; @@ -697,10 +698,9 @@ ucs2cpy(filepath, src->name); ucs2cat(filepath, plp_ext); + dst->filename = ucs2dup(filepath); - dst->filename = ucs2dup(filepath_skippath(filepath)); - - filepath_remove_filespec(filepath); + filepath_combinepath(filepath, MAX_PATH, rootdir, music->pmp->info.path_to_playlist); filepath_addslash(filepath); dst->filepath = ucs2dup(filepath_skipdrive(filepath, music->pmp->info.path_to_root)); filepath_slash(dst->filepath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 01:21:32
|
Revision: 280 http://svn.sourceforge.net/pmplib/?rev=280&view=rev Author: nyaochi Date: 2007-01-25 17:21:22 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Library restructuring for MSVC2005: - filepath.dll -> filepath.lib (static) - ucs2.dll -> ucs2.lib (static) pmp.dll now depends to filepath.lib and ucs2.lib. Modified Paths: -------------- trunk/pmplib/lib/filepath/filepath.vcproj trunk/pmplib/lib/ucs2/ucs2.vcproj trunk/pmplib/pmp.sln Modified: trunk/pmplib/lib/filepath/filepath.vcproj =================================================================== --- trunk/pmplib/lib/filepath/filepath.vcproj 2007-01-26 01:12:08 UTC (rev 279) +++ trunk/pmplib/lib/filepath/filepath.vcproj 2007-01-26 01:21:22 UTC (rev 280) @@ -18,7 +18,7 @@ Name="Debug|Win32" OutputDirectory="$(SolutionDir)debug" IntermediateDirectory="Debug" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" CharacterSet="2" > @@ -60,22 +60,12 @@ Name="VCPreLinkEventTool" /> <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/filepath.dll" - LinkIncremental="2" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(OutDir)/filepath.pdb" - SubSystem="2" - ImportLibrary="$(OutDir)/filepath.lib" - TargetMachine="1" + Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool - Name="VCManifestTool" - /> - <Tool Name="VCXDCMakeTool" /> <Tool @@ -85,12 +75,6 @@ Name="VCFxCopTool" /> <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> Modified: trunk/pmplib/lib/ucs2/ucs2.vcproj =================================================================== --- trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-01-26 01:12:08 UTC (rev 279) +++ trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-01-26 01:21:22 UTC (rev 280) @@ -18,7 +18,7 @@ Name="Debug|Win32" OutputDirectory="$(SolutionDir)debug" IntermediateDirectory="Debug" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" CharacterSet="2" > @@ -60,22 +60,12 @@ Name="VCPreLinkEventTool" /> <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/ucs2.dll" - LinkIncremental="2" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(OutDir)/ucs2.pdb" - SubSystem="2" - ImportLibrary="$(OutDir)/ucs2.lib" - TargetMachine="1" + Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool - Name="VCManifestTool" - /> - <Tool Name="VCXDCMakeTool" /> <Tool @@ -85,12 +75,6 @@ Name="VCFxCopTool" /> <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> Modified: trunk/pmplib/pmp.sln =================================================================== --- trunk/pmplib/pmp.sln 2007-01-26 01:12:08 UTC (rev 279) +++ trunk/pmplib/pmp.sln 2007-01-26 01:21:22 UTC (rev 280) @@ -10,68 +10,53 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmi", "lib\gmi\gmi.vcproj", "{3575EFC2-9051-467A-BEB4-E71E2F8664D7}" ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp", "lib\pmp\pmp.vcproj", "{8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A}" ProjectSection(ProjectDependencies) = postProject - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} + {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_irivnavi", "lib\pmp_irivnavi\pmp_irivnavi.vcproj", "{2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1}" ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_iriverplus2", "lib\pmp_iriverplus2\pmp_iriverplus2.vcproj", "{E393575C-6B10-43BD-B2C0-63C5040A49F7}" ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playlist", "lib\playlist\playlist.vcproj", "{3419FA86-F518-4D3B-94C6-B05436439102}" ProjectSection(ProjectDependencies) = postProject - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} + {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "easypmp_cui", "frontend\easypmp\cui\easypmp_cui.vcproj", "{FA1F30D4-6100-4379-8506-6CFE023B0AE7}" ProjectSection(ProjectDependencies) = postProject - {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} + {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} + {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "easypmp_win32gui", "frontend\easypmp\win32gui\easypmp_win32gui.vcproj", "{45CCFC7B-42B4-4FF9-AF43-FC3626B1672F}" ProjectSection(ProjectDependencies) = postProject - {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} - {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} + {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} + {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} + {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} + {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_portalplayer1", "lib\pmp_portalplayer1\pmp_portalplayer1.vcproj", "{544769C2-6989-452F-B626-E442CAC6553B}" ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_iriverplus3", "lib\pmp_iriverplus3\pmp_iriverplus3.vcproj", "{C74FE9C9-B5C4-438A-B157-9BCB6C8A7546}" ProjectSection(ProjectDependencies) = postProject {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} - {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} EndProjectSection EndProject Global This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 02:36:02
|
Revision: 281 http://svn.sourceforge.net/pmplib/?rev=281&view=rev Author: nyaochi Date: 2007-01-25 18:36:01 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Synchronize pmp_iriverplus2 with the latest API. Modified Paths: -------------- trunk/pmplib/include/pmp.h trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.h trunk/pmplib/lib/pmp_iriverplus2/playlist.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/include/pmp.h 2007-01-26 02:36:01 UTC (rev 281) @@ -619,6 +619,9 @@ PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist); PMPAPI void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src); +PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlist, int num_playlists); +PMPAPI void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists); + /** * @} */ Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-26 02:36:01 UTC (rev 281) @@ -106,3 +106,20 @@ dst->entries[i] = ucs2dup(src->entries[i]); } } + +void pmplib_playlists_finish(pmp_playlist_t* playlists, int num_playlists) +{ + int i; + for (i = 0;i < num_playlists;++i) { + pmplib_playlist_finish(&playlists[i]); + } + ucs2free(playlists); +} + +void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists) +{ + int i; + for (i = 0;i < num_playlists;++i) { + pmplib_playlist_clone(&dst[i], &src[i]); + } +} Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.h =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.h 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.h 2007-01-26 02:36:01 UTC (rev 281) @@ -277,10 +277,12 @@ // playlist.c int ip2db_playlist_write( ip2db_t* db, - const ucs2char_t *filename, + const ucs2char_t *name, ucs2char_t* const mediafiles[], int num_mediafiles, - const ucs2char_t *path_to_root + const ucs2char_t *path_to_root, + const ucs2char_t *path_to_playlist, + const ucs2char_t *ext ); #endif/*__IP2DB_IP2DB_H__*/ Modified: trunk/pmplib/lib/pmp_iriverplus2/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-01-26 02:36:01 UTC (rev 281) @@ -92,17 +92,25 @@ int ip2db_playlist_write( ip2db_t* db, - const ucs2char_t *filename, + const ucs2char_t *name, ucs2char_t* const mediafiles[], int num_mediafiles, - const ucs2char_t *path_to_root + const ucs2char_t *path_to_root, + const ucs2char_t *path_to_playlist, + const ucs2char_t *ext ) { int i; FILE *fp = NULL; uint32_t* recids = NULL; uint32_t num_recids = 0; + ucs2char_t dst[MAX_PATH]; + filepath_combinepath(dst, MAX_PATH, path_to_root, path_to_playlist); + filepath_addslash(dst); + ucs2cat(dst, name); + ucs2cat(dst, ext); + for (i = 0;i < num_mediafiles;i++) { if (mediafiles[i][0]) { uint32_t recid = 0; @@ -124,7 +132,7 @@ } } - fp = ucs2fopen(filename, "wb"); + fp = ucs2fopen(dst, "wb"); if (fp) { size_t size = sizeof(uint32_t) + sizeof(uint32_t) * num_recids; uint8_t* buffer = (uint8_t*)malloc(size); Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-26 02:36:01 UTC (rev 281) @@ -54,6 +54,9 @@ const char *sys_filename; const char *dat_filename; const char *idx_filename; + const char *extensions; + uint32_t codecs[8]; + const char *path_to_system; const char *path_to_music; const char *path_to_playlist; const char *playlist_ext; @@ -64,151 +67,169 @@ "iriver_h10jr_ums_1.00-1.61", "iriver", "H10Jr UMS", "UM", "1.00", "1.61", "System\\H10_Jr.SYS", "System\\H10_Jr.DAT", "System\\H10_Jr.IDX", - "Music\\", "Playlists\\", + ".mp3\0.ogg\0.wma\0.wav\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, + "System\\", "Music\\", "Playlists\\", ".plp", }, { "iriver_u10_ums_1.00-1.65", "iriver", "U10 UMS", "UM", "1.00", "1.65", "System\\U10.SYS", "System\\U10.dat", "System\\U10.idx", - "Music\\", "Playlists\\", + ".mp3\0.ogg\0.wma\0.wav\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, + "System\\", "Music\\", "Playlists\\", ".plp", }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, + {0, 0, 0, 0, 0, 0, 0, 0}, + NULL, NULL, NULL, + NULL, }, }; typedef struct { - char id[128]; - char name[128]; - char mode[128]; - char language[128]; - char version[128]; - - ucs2char_t path_to_root[MAX_PATH]; - ucs2char_t path_to_music[MAX_PATH]; - ucs2char_t path_to_playlist[MAX_PATH]; - ucs2char_t sys_filename[MAX_PATH]; - ucs2char_t dat_filename[MAX_PATH]; - ucs2char_t idx_filename[MAX_PATH]; - ucs2char_t playlist_ext[MAX_PATH]; -} ip2_environment_t; - - -typedef struct { - ip2_environment_t env; + const ip2model_descriptor_t* decl; } pmp_internal_t; typedef struct { ip2db_t ip2db; -} pmpdb_internal_t; + pmp_music_record_t* records; + int num_records; + pmp_playlist_t* playlists; + int num_playlists; +} pmp_music_internal_t; -typedef struct { - ip2db_t ip2db; -} pmppl_internal_t; - - static uint32_t pmp_add_ref(pmp_t* pmp); static uint32_t pmp_release(pmp_t* pmp); static result_t pmp_open(pmp_t* pmp, uint32_t flag); -static result_t pmp_close(pmp_t* pmp, uint32_t flag); -static result_t pmp_create_instance_db(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static result_t pmp_create_instance_pl(pmp_t* pmp, pmp_playlist_t** ptr_pmppl); +static result_t pmp_close(pmp_t* pmp); +static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_pmpdb); -static uint32_t pmpdb_release(pmp_music_t* pmpdb); -static result_t pmpdb_read(pmp_music_t* pmpdb); -static result_t pmpdb_write(pmp_music_t* pmpdb); -static result_t pmpdb_set(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records); -static result_t pmpdb_get(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records); -static result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level); -static int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec); -static int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename); +static uint32_t pmpmusic_release(pmp_music_t* music); +static uint32_t pmpmusic_open(pmp_music_t* music); +static uint32_t pmpmusic_close(pmp_music_t* music); +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records); +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level); +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); -static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl); -static uint32_t pmppl_release(pmp_playlist_t* pmppl); -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files); +#define COMP(a, b) ((a)>(b))-((a)<(b)) -static void set_environment( - ip2_environment_t* env, +static char* strip(char *str) +{ + char *p = str + strlen(str) - 1; + while (*str && isspace(*str)) { + str++; + } + while (str <= p && isspace(*p)) { + *p-- = 0; + } + return str; +} + +static const char *strcpy_if_empty(char *dst, const char *src) +{ + return *dst ? dst : strcpy(dst, src); +} + +static void set_device_info( + const char *id, + const ucs2char_t* path_to_device, const ip2model_descriptor_t* md, - const ucs2char_t* path_to_device + pmp_device_information_t* info ) { + uint32_t n; + const char *p = NULL; ucs2char_t* ucs2 = NULL; + pmp_device_description_t* decl = (pmp_device_description_t*)&info->decl; - ucs2cpy(env->path_to_root, path_to_device); + strcpy_if_empty(decl->id, id); + strcpy_if_empty(decl->manufacturer, md->manufacturer); + strcpy_if_empty(decl->name, md->name); + strcpy_if_empty(decl->mode, md->mode); + //strcpy_if_empty(decl->language, md->language); + //strcpy_if_empty(decl->version, md->version); + strcpy_if_empty(decl->min_version, md->min_version); + strcpy_if_empty(decl->max_version, md->max_version); - ucs2cpy(env->path_to_music, path_to_device); - filepath_addslash(env->path_to_music); + ucs2cpy(info->path_to_root, path_to_device); + + ucs2 = mbsdupucs2(md->path_to_system); + ucs2cpy(info->path_to_system, ucs2); + ucs2free(ucs2); + ucs2 = mbsdupucs2(md->path_to_music); - ucs2cat(env->path_to_music, ucs2); + ucs2cpy(info->path_to_music, ucs2); ucs2free(ucs2); - ucs2cpy(env->path_to_playlist, path_to_device); - filepath_addslash(env->path_to_playlist); ucs2 = mbsdupucs2(md->path_to_playlist); - ucs2cat(env->path_to_playlist, ucs2); + ucs2cpy(info->path_to_playlist, ucs2); ucs2free(ucs2); - ucs2cpy(env->sys_filename, path_to_device); - filepath_addslash(env->sys_filename); - ucs2 = mbsdupucs2(md->sys_filename); - ucs2cat(env->sys_filename, ucs2); - ucs2free(ucs2); + info->music_flag = PMPMF_SUPPORT | PMPMF_RECURSIVE; + info->playlist_flag = PMPPF_SUPPORT; - ucs2cpy(env->dat_filename, path_to_device); - filepath_addslash(env->dat_filename); - ucs2 = mbsdupucs2(md->dat_filename); - ucs2cat(env->dat_filename, ucs2); - ucs2free(ucs2); + // Audio codecs. + for (n = 0;md->codecs[n];++n) ; + info->num_audio_codecs = n; + info->audio_codecs = (uint32_t*)ucs2malloc(sizeof(uint32_t) * info->num_audio_codecs); + for (n = 0;n < info->num_audio_codecs;++n) { + info->audio_codecs[n] = md->codecs[n]; + } - ucs2cpy(env->idx_filename, path_to_device); - filepath_addslash(env->idx_filename); - ucs2 = mbsdupucs2(md->idx_filename); - ucs2cat(env->idx_filename, ucs2); - ucs2free(ucs2); + // Obtain the number of extensions separated by '\0' characters. + for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { + n++; + } + info->num_audio_extensions = n; + info->audio_extensions = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * info->num_audio_extensions); + for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { + info->audio_extensions[n++] = mbsdupucs2(p); + } +} - ucs2 = mbsdupucs2(md->playlist_ext); - ucs2cat(env->playlist_ext, ucs2); - ucs2free(ucs2); +static void free_device_info(pmp_device_information_t* info) +{ + uint32_t i; + for (i = 0;i < info->num_audio_extensions;++i) { + ucs2free(info->audio_extensions[i]); + } + ucs2free(info->audio_codecs); + ucs2free(info->audio_extensions); + memset(info, 0, sizeof(*info)); } -static int match_model( - const char *id, - const ucs2char_t* path_to_device, - const ip2model_descriptor_t* md, - ip2_environment_t* env - ) +static void set_filenames(ucs2char_t *sys, ucs2char_t *dat, ucs2char_t *idx, pmp_t *pmp) { - memset(env, 0, sizeof(*env)); + ucs2char_t* ucs2 = NULL; + pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - if (!id || strcmp(md->id, id) != 0) { - return 0; - } + ucs2cpy(sys, pmp->info.path_to_root); + filepath_addslash(sys); + ucs2 = mbsdupucs2(pmpi->decl->sys_filename); + ucs2cat(sys, ucs2); + ucs2free(ucs2); - set_environment(env, md, path_to_device); - return 1; -} + ucs2cpy(dat, pmp->info.path_to_root); + filepath_addslash(dat); + ucs2 = mbsdupucs2(pmpi->decl->dat_filename); + ucs2cat(dat, ucs2); + ucs2free(ucs2); -static char* strip(char *str) -{ - char *p = str + strlen(str) - 1; - while (*str && isspace(*str)) { - str++; - } - while (str <= p && isspace(*p)) { - *p-- = 0; - } - return str; + ucs2cpy(idx, pmp->info.path_to_root); + filepath_addslash(idx); + ucs2 = mbsdupucs2(pmpi->decl->idx_filename); + ucs2cat(idx, ucs2); + ucs2free(ucs2); } -#define COMP(a, b) ((a)>(b))-((a)<(b)) static int compare_version(const char *x, const char *y) { @@ -232,19 +253,22 @@ static int detect_model( const ucs2char_t* path_to_device, const ip2model_descriptor_t* md, - ip2_environment_t* env + pmp_device_information_t* ptr_info ) { ucs2char_t* ucs2 = NULL; ucs2char_t filename[MAX_PATH]; + pmp_device_description_t decl; - memset(env, 0, sizeof(*env)); + memset(&decl, 0, sizeof(decl)); + // filename = "${path_to_device}/${md->sys_filename}" ucs2cpy(filename, path_to_device); filepath_addslash(filename); ucs2 = mbsdupucs2(md->sys_filename); ucs2cat(filename, ucs2); ucs2free(ucs2); + if (filepath_file_exists(filename)) { int match = 1; char line[128]; @@ -257,23 +281,23 @@ char *p = strip(line); if (p[0] == '[' && line[strlen(p)-1] == ']') { p[strlen(p)-1] = 0; - strcpy(env->name, p+1); + strcpy(decl.name, p+1); } else if (strncmp(p, "version = ", 10) == 0) { - strcpy(env->version, p+10); + strcpy(decl.version, p+10); } else if (strncmp(p, "language = ", 11) == 0) { - strcpy(env->language, p+11); + strcpy(decl.language, p+11); } else if (strncmp(p, "mode = ", 7) == 0) { - strcpy(env->mode, p+7); + strcpy(decl.mode, p+7); } } fclose(fp); - match &= (strcmp(env->mode, md->mode) == 0); - match &= (compare_version(md->min_version, env->version) <= 0); - match &= (compare_version(env->version, md->max_version) <= 0); + match &= (strcmp(decl.mode, md->mode) == 0); + match &= (compare_version(md->min_version, decl.version) <= 0); + match &= (compare_version(decl.version, md->max_version) <= 0); if (match) { - set_environment(env, md, path_to_device); + memcpy((pmp_device_description_t*)&ptr_info->decl, &decl, sizeof(decl)); return 1; } } @@ -297,25 +321,32 @@ pmp_t* pmp = NULL; pmp_internal_t* pmpi = NULL; const ip2model_descriptor_t* md = NULL; - ip2_environment_t env; - pmp_device_environment_t* pmpenv = NULL; + pmp_device_information_t info; + // Initialize device information. + memset(&info, 0, sizeof(info)); + + // Return a NULL pointer by default. *ptr_pmp = 0; // Find a suitable model for the device. md = g_model_descriptions; for (;md->id;++md) { - if (detect_model(path_to_device, md, &env)) { - if (!id || !id[0]) { + if (id && *id) { + // Match the device identifier. + if (strcmp(md->id, id) == 0) { + // This will fill some members in decl. + detect_model(path_to_device, md, &info); + set_device_info(id, path_to_device, md, &info); break; } - if (strcmp(md->id, id) == 0) { + } else { + // Detect the model automatically. + if (detect_model(path_to_device, md, &info)) { + set_device_info(md->id, path_to_device, md, &info); break; } } - if (match_model(id, path_to_device, md, &env)) { - break; - } } if (!md->id) { return PMP_DEVICENOTFOUND; @@ -331,41 +362,22 @@ pmp->release = pmp_release; pmp->open = pmp_open; pmp->close = pmp_close; - pmp->create_instance_pl = pmp_create_instance_pl; pmp->add_ref(pmp); // Allocate the internal variables. pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { - pmp_release(pmp); + free(pmp); return PMPDBE_OUTOFMEMORY; } - pmp->instance = pmpi; + pmpi->decl = md; // Initialize the internal variables. - memcpy(&pmpi->env, &env, sizeof(env)); + pmp->instance = pmpi; + memcpy((pmp_device_information_t*)&pmp->info, &info, sizeof(info)); - // Initialize the (exportable) env. - strcpy(pmp->decl.id, md->id); - strcpy(pmp->decl.manufacturer, md->manufacturer); - strcpy(pmp->decl.name, md->name); - strcpy(pmp->decl.mode, md->mode); - strcpy(pmp->decl.language, pmpi->env.language); - strcpy(pmp->decl.version, pmpi->env.version); - strcpy(pmp->decl.min_version, md->min_version); - strcpy(pmp->decl.max_version, md->max_version); - - pmpenv = &pmp->env; - pmpenv->path_to_root.flag = PMPPEF_SUPPORT | PMPPEF_CONSTANT; - ucs2cpy(pmpenv->path_to_root.path, pmpi->env.path_to_root); - pmpenv->path_to_music.flag = PMPPEF_SUPPORT | PMPPEF_RECURSIVE; - ucs2cpy(pmpenv->path_to_music.path, pmpi->env.path_to_music); - pmpenv->path_to_playlist.flag = PMPPEF_SUPPORT; - ucs2cpy(pmpenv->path_to_playlist.path, pmpi->env.path_to_playlist); - ucs2cpy(pmpenv->playlist_ext, pmpi->env.playlist_ext); - // Create music instance. - ret = pmp_create_instance_db(pmp, &pmp->music); + ret = pmp_create_instance_music(pmp, &pmp->music); if (ret != 0) { pmp_release(pmp); return ret; @@ -385,7 +397,8 @@ { uint32_t count = pmplib_interlocked_decrement(&pmp->ref_count); if (count == 0) { - pmpdb_release(pmp->music); + pmpmusic_release(pmp->music); + free_device_info(&pmp->info); free(pmp->instance); free(pmp); } @@ -395,140 +408,240 @@ static result_t pmp_open(pmp_t* pmp, uint32_t flag) { result_t ret = 0; + + // Set the open flag. pmp->flag = flag; - if (pmp->flag & PMPOF_MUSIC_DB_READ) { - ret = pmpdb_read(pmp->music); - if (ret != 0) { - return ret; - } + // Open the music database. + ret = pmpmusic_open(pmp->music); + if (ret) { + return ret; } + return 0; } -static result_t pmp_close(pmp_t* pmp, uint32_t flag) +static result_t pmp_close(pmp_t* pmp) { result_t ret = 0; - if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { - ret = pmpdb_write(pmp->music); - if (ret != 0) { - return ret; - } + + // Close the music database. + ret = pmpmusic_close(pmp->music); + if (ret) { + return ret; } + return 0; } -static result_t pmp_create_instance_db(pmp_t* pmp, pmp_music_t** ptr_pmpdb) +static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_music) { - pmp_music_t* pmpdb = NULL; + pmp_music_t* music = NULL; pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmpdb_internal_t* pmpdbi = NULL; + pmp_music_internal_t* pmpmi = NULL; - *ptr_pmpdb = 0; + *ptr_music = 0; - pmpdb = calloc(1, sizeof(pmp_music_t)); - if (!pmpdb) { + music = calloc(1, sizeof(pmp_music_t)); + if (!music) { return PMPDBE_OUTOFMEMORY; } - pmpdb->set = pmpdb_set; - pmpdb->get = pmpdb_get; - pmpdb->dump = pmpdb_dump; - pmpdb->is_supported_codec = pmpdb_is_supported_codec; - pmpdb->is_supported_ext = pmpdb_is_supported_ext; - - pmpdbi = calloc(1, sizeof(pmpdb_internal_t)); - if (!pmpdbi) { - free(pmpdb); + pmpmi = calloc(1, sizeof(pmp_music_internal_t)); + if (!pmpmi) { + free(music); return PMPDBE_OUTOFMEMORY; } - ip2db_init(&pmpdbi->ip2db); + ip2db_init(&pmpmi->ip2db); - pmpdb->pmp = pmp; - pmpdb->instance = pmpdbi; + music->set_records = pmpmusic_set_records; + music->get_records = pmpmusic_get_records; + music->dump = pmpmusic_dump; + music->set_playlists = pmpmusic_set_playlists; + music->pmp = pmp; + music->instance = pmpmi; - *ptr_pmpdb = pmpdb; + *ptr_music = music; return 0; } -static result_t pmp_create_instance_pl(pmp_t* pmp, pmp_playlist_t** ptr_pmppl) + + + + + +static uint32_t pmpmusic_release(pmp_music_t* music) { - pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmp_playlist_t* pmppl = NULL; - pmppl_internal_t* pmppli = NULL; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + ip2db_finish(&pmpmi->ip2db); + pmplib_records_finish(pmpmi->records, pmpmi->num_records); + free(pmpmi->playlists); + free(pmpmi); + free(music); + return 0; +} - *ptr_pmppl = 0; +static uint32_t pmpmusic_open(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; - pmppl = calloc(1, sizeof(pmp_playlist_t)); - if (!pmppl) { - return PMPDBE_OUTOFMEMORY; + // Free the existing records. + pmplib_records_finish(pmpmi->records, pmpmi->num_records); + pmpmi->records = 0; + pmpmi->num_records = 0; + + // Open the music database if necessary. + if (pmp->flag & PMPOF_MUSIC_DB_READ) { + ucs2char_t sys[MAX_PATH], dat[MAX_PATH], idx[MAX_PATH]; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + + // Read the music database. + set_filenames(sys, dat, idx, pmp); + ret = ip2db_read(&pmpmi->ip2db, dat, idx); + if (ret) { + return ret; + } + + return ip2db_get(&pmpmi->ip2db, pmpmi->records, &pmpmi->num_records, pmp->info.path_to_root); } - pmppl->add_ref = pmppl_add_ref; - pmppl->release = pmppl_release; - pmppl->write = pmppl_write; + return 0; +} - pmppli = calloc(1, sizeof(pmppl_internal_t)); - if (!pmppli) { - free(pmppl); - return PMPDBE_OUTOFMEMORY; +static uint32_t pmpmusic_close(pmp_music_t* music) +{ + result_t ret = 0; + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + static const ucs2char_t plp_ext[] = {'.','p','l','p',0}; + + if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + ucs2char_t sys[MAX_PATH], dat[MAX_PATH], idx[MAX_PATH]; + + ip2db_set(&pmpmi->ip2db, pmpmi->records, pmpmi->num_records, pmp->info.path_to_root); + + set_filenames(sys, dat, idx, pmp); + ret = ip2db_write(&pmpmi->ip2db, dat, idx); + if (ret) { + return ret; + } } - ip2db_init(&pmppli->ip2db); - ip2db_read(&pmppli->ip2db, pmpi->env.dat_filename, pmpi->env.idx_filename); - pmppl->pmp = pmp; - pmppl->instance = pmppli; + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + int i; - pmppl->add_ref(pmppl); - *ptr_pmppl = pmppl; + for (i = 0;i < pmpmi->num_playlists;++i) { + const pmp_playlist_t* pl = &pmpmi->playlists[i]; + if (ip2db_playlist_write( + &pmpmi->ip2db, + pl->name, + pl->entries, + pl->num_entries, + pmp->info.path_to_root, + pmp->info.path_to_playlist, + plp_ext + ) != 0) { + return PMPPLE_WRITE; + } + } + } + + return ret; +} + +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records) +{ + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + /* Free records attached to pmpmi. */ + pmplib_records_finish(pmpmi->records, pmpmi->num_records); + + /* Allocate new records. */ + pmpmi->records = (pmp_music_record_t*)ucs2malloc(sizeof(pmp_music_record_t) * num_records); + pmpmi->num_records = num_records; + pmplib_records_clone(pmpmi->records, records, num_records); + return 0; + } + +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records) +{ + pmp_t* pmp = music->pmp; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + + if (!records) { + *num_records = pmpmi->num_records; + return 0; + } else if (*num_records == pmpmi->num_records) { + pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); + return 0; + } else { + return PMPDBE_INSUFFICIENT; + } } +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) +{ + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + if (level > 0) { + return ip2db_repr(&pmpmi->ip2db, fp); + } else { + return ip2db_dump(&pmpmi->ip2db, fp); + } +} +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists) +{ + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + // Free playlists attached to pmpmi. + pmplib_playlists_finish(pmpmi->playlists, pmpmi->num_playlists); + // Allocate a new playlists. + pmpmi->playlists = (pmp_playlist_t*)calloc(num_playlists, sizeof(pmp_playlist_t)); + pmpmi->num_playlists = num_playlists; + // Copy the playlist array. + pmplib_playlists_clone(pmpmi->playlists, playlists, num_playlists); -static uint32_t pmpdb_release(pmp_music_t* pmpdb) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - ip2db_finish(&pmpdbi->ip2db); - free(pmpdb->instance); - free(pmpdb); return 0; } +/* static result_t pmpdb_read(pmp_music_t* pmpdb) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; return ip2db_read(&pmpdbi->ip2db, pmpi->env.dat_filename, pmpi->env.idx_filename); } static result_t pmpdb_write(pmp_music_t* pmpdb) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; return ip2db_write(&pmpdbi->ip2db, pmpi->env.dat_filename, pmpi->env.idx_filename); } static result_t pmpdb_set(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; return ip2db_set(&pmpdbi->ip2db, records, num_records, pmpi->env.path_to_root); } static result_t pmpdb_get(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; return ip2db_get(&pmpdbi->ip2db, records, num_records, pmpi->env.path_to_root); } static result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; + pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; if (level > 0) { return ip2db_repr(&pmpdbi->ip2db, fp); } else { @@ -575,3 +688,4 @@ } return 0; } +*/ \ No newline at end of file Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-26 01:21:22 UTC (rev 280) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-01-26 02:36:01 UTC (rev 281) @@ -80,7 +80,7 @@ NULL, NULL, NULL, NULL, NULL, {0, 0, 0, 0, 0, 0, 0, 0}, - NULL, NULL, + NULL, NULL, NULL, NULL, }, }; @@ -186,8 +186,6 @@ for (n = 0, p = md->extensions;*p;p += (strlen(p)+1)) { info->audio_extensions[n++] = mbsdupucs2(p); } - - } static void free_device_info(pmp_device_information_t* info) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 15:39:13
|
Revision: 287 http://svn.sourceforge.net/pmplib/?rev=287&view=rev Author: nyaochi Date: 2007-01-26 07:39:06 -0800 (Fri, 26 Jan 2007) Log Message: ----------- Prevent a possible problem in byte-order conversion. I found a node converted twice since it was referred by multiple indices in a database updated by the player. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/lib/pmp_iriverplus3/idx.c Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 13:27:21 UTC (rev 286) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 15:39:06 UTC (rev 287) @@ -155,7 +155,7 @@ int this_option_optind = optind ? optind : 1; int option_index = 0; static const struct option long_options[] = { - {"create", no_argument, 0, 'c'}, + {"create", no_argument, 0, 'c'}, {"update", no_argument, 0, 'u'}, {"source", required_argument, 0, 'z'}, {"repr", no_argument, 0, 'R'}, Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 13:27:21 UTC (rev 286) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 15:39:06 UTC (rev 287) @@ -84,6 +84,7 @@ uint8_t* buffer; uint32_t size; uint32_t offset; + uint8_t* be_flag; }; typedef int (*avl_comp_t)(avl_t* avl, uint32_t x, uint32_t y); @@ -96,6 +97,7 @@ static void avl_finish(avl_t* avl) { free(avl->buffer); + free(avl->be_flag); free(avl); } @@ -148,7 +150,12 @@ static void avl_rewind(avl_t* avl, uint32_t offset) { memset(avlnode(avl, offset), 0, avl->offset - offset); - avl->offset = offset; + //if (avl->offset / PAGESIZE == offset / PAGESIZE) { + avl->offset = offset; + /*} else { + uint32_t page = avl->offset / PAGESIZE; + avl->offset = PAGESIZE * page + sizeof(header_t); + }*/ } static uint32_t avlnode_new(avl_t* avl, size_t keysize) @@ -493,6 +500,14 @@ int field = dic_table->indices[index].fields[level]; int type = dic_table->fields[field].type; + /* Skip this node if already converted to the native byte-order. */ + if (avl->be_flag[offset]) { + return; + } + + /* This node is converted to the native byte-order. */ + avl->be_flag[offset] = 1; + /* Convert the current node. */ from_uint32be(&node->left); from_uint32be(&node->right); @@ -526,14 +541,16 @@ from_be_avltree(avl, node->tail, dic_table, index, level+1); } else { /* Convert the tail. */ - avltail_t* tail = (avltail_t*)avlnode(avl, node->tail); - for (;;) { + uint32_t tail_offset = node->tail; + while (!avl->be_flag[tail_offset]) { + avltail_t* tail = (avltail_t*)avlnode(avl, tail_offset); from_uint32be(&tail->next); from_uint32be(&tail->data); + avl->be_flag[tail_offset] = 1; /* Mark this tail. */ if (!tail->next) { break; } - tail = (avltail_t*)avlnode(avl, tail->next); + tail_offset = tail->next; } } } @@ -731,6 +748,14 @@ offset += PAGESIZE; } + /* + * Allocate memory block for indicating the status of byte-order conversion. + * This is really ugly, but we had to prevent a node from being converted twice. + * At first, I didn't think this treatment is necessary, but I found a node + * referred by multiple indices in a database generated by my E10 player. + */ + idx->avl->be_flag = calloc(idx->avl->size, 1); + /* Convert the byte order of values in AVL trees. */ for (i = 0;i < dic->music.num_indices;++i) { uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_MUSIC, i); @@ -750,6 +775,10 @@ from_be_avltree(idx->avl, idx_root, &dic->objects, i, 0); } } + + /* Free the memory block for big-endian flags. */ + free(idx->avl->be_flag); + idx->avl->be_flag = NULL; return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-27 09:00:34
|
Revision: 289 http://svn.sourceforge.net/pmplib/?rev=289&view=rev Author: nyaochi Date: 2007-01-27 01:00:28 -0800 (Sat, 27 Jan 2007) Log Message: ----------- - Fixed a bug in filepath_skiproot() for Win32 environment. - Removed an unnecessary option. - Make Win32 release build work. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/lib/filepath/filepath.vcproj trunk/pmplib/lib/filepath/filepath_win32.c trunk/pmplib/lib/ucs2/ucs2.vcproj Modified: trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj =================================================================== --- trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-01-26 15:59:23 UTC (rev 288) +++ trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-01-27 09:00:28 UTC (rev 289) @@ -120,7 +120,7 @@ Name="VCCLCompilerTool" AdditionalIncludeDirectories="$(SolutionDir)include,..\common" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" - RuntimeLibrary="0" + RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="true" Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-26 15:59:23 UTC (rev 288) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-27 09:00:28 UTC (rev 289) @@ -94,7 +94,6 @@ fprintf(fp, " -l, --list-device Show the list of supported devices and exit\n"); fprintf(fp, " -d, --device Specify a device identifier for the player\n"); fprintf(fp, " -s, --set=NAME=VALUE Set a variable NAME to VALUE\n"); - fprintf(fp, " -V, --show-variables Show list of variables and their default values\n"); fprintf(fp, "\n"); #ifndef _WIN32 fprintf(fp, "Language-specific options:\n"); @@ -169,7 +168,6 @@ {"list-device", no_argument, 0, 'l'}, {"device", required_argument, 0, 'd'}, {"set", required_argument, 0, 's'}, - {"show-variables", no_argument, 0, 'V'}, #ifndef _WIN32 {"encoding", required_argument, 0, 'e'}, {"tagencoding", required_argument, 0, 'w'}, @@ -244,8 +242,6 @@ break; case 's': break; - case 'V': - break; #ifndef _WIN32 case 'e': free(opt->system_encoding); @@ -253,7 +249,7 @@ break; case 'w': free(opt->music_encoding); - opt->music_encoding = optarg; + opt->music_encoding = strdup(optarg); break; #endif/*_WIN32*/ case 'v': Modified: trunk/pmplib/lib/filepath/filepath.vcproj =================================================================== --- trunk/pmplib/lib/filepath/filepath.vcproj 2007-01-26 15:59:23 UTC (rev 288) +++ trunk/pmplib/lib/filepath/filepath.vcproj 2007-01-27 09:00:28 UTC (rev 289) @@ -82,7 +82,7 @@ Name="Release|Win32" OutputDirectory="$(SolutionDir)release" IntermediateDirectory="Release" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" CharacterSet="2" > @@ -121,23 +121,12 @@ Name="VCPreLinkEventTool" /> <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/filepath.dll" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/filepath.lib" - TargetMachine="1" + Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool - Name="VCManifestTool" - /> - <Tool Name="VCXDCMakeTool" /> <Tool @@ -147,12 +136,6 @@ Name="VCFxCopTool" /> <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> Modified: trunk/pmplib/lib/filepath/filepath_win32.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_win32.c 2007-01-26 15:59:23 UTC (rev 288) +++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-01-27 09:00:28 UTC (rev 289) @@ -101,10 +101,11 @@ const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root) { - /* Ignore root for WIN32. */ - const ucs2char_t* p = PathSkipRootW(path); - if (!p) p = path; - return p; + if (ucs2ncmp(path, root, ucs2len(root)) == 0) { + return path + ucs2len(root); + } else { + return path; + } } const ucs2char_t* filepath_skippath(const ucs2char_t* path) Modified: trunk/pmplib/lib/ucs2/ucs2.vcproj =================================================================== --- trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-01-26 15:59:23 UTC (rev 288) +++ trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-01-27 09:00:28 UTC (rev 289) @@ -82,7 +82,7 @@ Name="Release|Win32" OutputDirectory="$(SolutionDir)release" IntermediateDirectory="Release" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" CharacterSet="2" > @@ -121,23 +121,12 @@ Name="VCPreLinkEventTool" /> <Tool - Name="VCLinkerTool" - OutputFile="$(OutDir)/ucs2.dll" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)\ucs2.lib" - TargetMachine="1" + Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool - Name="VCManifestTool" - /> - <Tool Name="VCXDCMakeTool" /> <Tool @@ -147,12 +136,6 @@ Name="VCFxCopTool" /> <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-29 14:07:33
|
Revision: 295 http://svn.sourceforge.net/pmplib/?rev=295&view=rev Author: nyaochi Date: 2007-01-29 06:07:30 -0800 (Mon, 29 Jan 2007) Log Message: ----------- Implemented UCS-2 functions similar to ANSI C string routines. We won't implement strcoll(), strtok(), and strxfrm() though. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-28 22:46:02 UTC (rev 294) +++ trunk/pmplib/include/ucs2char.h 2007-01-29 14:07:30 UTC (rev 295) @@ -69,29 +69,35 @@ UCS2API int isucs2space(ucs2char_t c); UCS2API int isucs2digit(ucs2char_t c); +UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); +UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); +UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); +UCS2API ucs2char_t* ucs2cpy(ucs2char_t* dst, const ucs2char_t* src); +UCS2API size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset); +UCS2API ucs2char_t* ucs2dup(const ucs2char_t* src); UCS2API size_t ucs2len(const ucs2char_t* string); -UCS2API ucs2char_t* ucs2cpy(ucs2char_t* dst, const ucs2char_t* src); +UCS2API ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count); +UCS2API int ucs2ncmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); UCS2API ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t count); -UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); - -UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); +UCS2API ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search); UCS2API ucs2char_t* ucs2rchr(const ucs2char_t* string, ucs2char_t c); - +UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); + + + + UCS2API ucs2char_t ucs2lower(ucs2char_t c); UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); UCS2API ucs2char_t ucs2upper(ucs2char_t c); UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); -UCS2API ucs2char_t* ucs2dup(const ucs2char_t* src); UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); -UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); -UCS2API int ucs2ncmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-28 22:46:02 UTC (rev 294) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-29 14:07:30 UTC (rev 295) @@ -103,6 +103,63 @@ return dst; } +size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = charset;*q;++q) { + if (*p == *q) { + return (p - str); + } + } + } + return (p - str); +} + +size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = charset;*q;++q) { + if (*p != *q) { + return (p - str); + } + } + } + return (p - str); +} + +ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = search;*q;++q) { + if (*p == *q) { + return (ucs2char_t*)p; + } + } + } + return NULL; +} + +ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count) +{ + size_t i; + ucs2char_t *p = dst + ucs2len(dst); + for (i = 0;i < count;i++) { + *p = *src; + if (!*src) { + break; + } + p++; + src++; + } + return dst; +} + ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t count) { size_t i; @@ -118,6 +175,7 @@ return dst; } + ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c) { ucs2char_t* ret = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-30 15:43:37
|
Revision: 296 http://svn.sourceforge.net/pmplib/?rev=296&view=rev Author: nyaochi Date: 2007-01-30 07:43:25 -0800 (Tue, 30 Jan 2007) Log Message: ----------- Removed unused functions in libucs2. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/include/ucs2char.h 2007-01-30 15:43:25 UTC (rev 296) @@ -38,12 +38,23 @@ #endif/*__cplusplus*/ /** - * \addtogroup ucs2 + * \addtogroup ucs2 PMPlib UCS-2 API. * @{ */ +/** + * Type definition of a UCS-2 character. + */ typedef uint16_t ucs2char_t; + + + +/** + * @defgroup ucs2_conv Charaset conversion routines. + * @{ + */ + struct tag_ucs2conv { const char *from; const char *to; @@ -51,24 +62,53 @@ typedef struct tag_ucs2conv ucs2conv_t; UCS2API int ucs2init(const char *encoding); -UCS2API int ucs2check(ucs2conv_t* conv); UCS2API int ucs2set_encoding(const char *encoding, ucs2conv_t* conv); UCS2API int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv); UCS2API void ucs2set_codepage(int cp); +UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); +UCS2API size_t mbstoucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +UCS2API size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); + +UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); +UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); +UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); +UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); + +/** + * @} + */ + + + UCS2API void ucs2big2little(ucs2char_t* value); +/** + * @defgroup ucs2_memory Memory allocation routines. + * @{ + */ + UCS2API void *ucs2malloc(size_t size); UCS2API void *ucs2calloc(size_t size); UCS2API void *ucs2realloc(void *ptr, size_t size); UCS2API void ucs2free(void* str); +/** + * @} + */ + UCS2API int is_ucs2surrogate(ucs2char_t c); UCS2API int isucs2space(ucs2char_t c); UCS2API int isucs2digit(ucs2char_t c); +/** + * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @{ + */ + UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); @@ -84,46 +124,38 @@ UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); +/** + * @} + */ +/** + * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @{ + */ +UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); +UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); +UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); +UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); +UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); +/** + * @} + */ + UCS2API ucs2char_t ucs2lower(ucs2char_t c); -UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); UCS2API ucs2char_t ucs2upper(ucs2char_t c); -UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); -UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); -UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); -UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); -UCS2API int ucs2memcmp(const ucs2char_t* buf1, const ucs2char_t* buf2, size_t count); -UCS2API const ucs2char_t *ucs2memchr(const ucs2char_t* buf, ucs2char_t c, size_t count); -UCS2API ucs2char_t *ucs2memmove(ucs2char_t *dest, const ucs2char_t *src, size_t count); -UCS2API ucs2char_t *ucs2memcpy(ucs2char_t *dest, const ucs2char_t *src, size_t count); -UCS2API ucs2char_t *ucs2memset(ucs2char_t *dest, ucs2char_t c, size_t count); - -UCS2API ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str); -UCS2API ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str); - UCS2API int ucs2toi(const ucs2char_t* str); UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); -UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); -UCS2API size_t mbstoucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); -UCS2API size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); -UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); - -UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); -UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); -UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); -UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); - UCS2API time_t ucs2stat_mtime(const ucs2char_t *filename); UCS2API uint32_t ucs2stat_size(const ucs2char_t *filename); UCS2API int ucs2stat_is_dir(const ucs2char_t *filename); Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-30 15:43:25 UTC (rev 296) @@ -269,52 +269,6 @@ return COMP(ucs2upper(*x), ucs2upper(*y)); } -int ucs2memcmp(const ucs2char_t* buf1, const ucs2char_t* buf2, size_t count) -{ - size_t i; - for (i = 0;i < count-1;i++) { - if (!*buf1 || !*buf2 || *buf1 != *buf2) { - break; - } - buf1++; - buf2++; - } - return COMP(*buf1, *buf2); -} - -const ucs2char_t *ucs2memchr(const ucs2char_t* buf, ucs2char_t c, size_t count) -{ - size_t i; - for (i = 0;i < count;++i) { - if (*buf == c) { - return buf; - } - buf++; - } - return NULL; -} - -ucs2char_t *ucs2memmove(ucs2char_t *dest, const ucs2char_t *src, size_t count) -{ - memmove(dest, src, sizeof(ucs2char_t) * count); - return dest; -} - -ucs2char_t *ucs2memcpy(ucs2char_t *dest, const ucs2char_t *src, size_t count) -{ - memcpy(dest, src, sizeof(ucs2char_t) * count); - return dest; -} - -ucs2char_t *ucs2memset(ucs2char_t *dest, ucs2char_t c, size_t count) -{ - size_t i; - for (i = 0;i < count;++i) { - *dest++ = c; - } - return dest; -} - ucs2char_t* ucs2dup(const ucs2char_t* src) { ucs2char_t* dst = (ucs2char_t*)malloc((ucs2len(src)+1) * sizeof(ucs2char_t)); @@ -456,47 +410,3 @@ } return dst; } - - -#define TEST_RIGHTTOLEFT - -#ifndef TEST_RIGHTTOLEFT - -ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str) -{ - /* Requiement: we must not increase the length of a string. */ - /* To be implemented. */ - return str; -} - -ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str) -{ - /* Requiement: we must not increase the length of a string. */ - /* To be implemented. */ - return str; -} - -#else - -ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str) -{ - if (str) { - ucs2char_t* p = str; - ucs2char_t* q = str + ucs2len(str) - 1; - for (;p < q;p++, q--) { - ucs2char_t tmp = *p; - *p = *q; - *q = tmp; - } - } - return str; -} - -ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str) -{ - return ucs2righttoleft_encode(str); -} - -/** @} */ - -#endif Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-30 15:43:25 UTC (rev 296) @@ -92,23 +92,8 @@ strcpy(g_encoding_music, encoding); } -int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +static int ucs2check(ucs2conv_t* conv) { - strncpy(g_encoding, encoding, sizeof(g_encoding)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); -} - -int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv) -{ - strncpy(g_encoding_music, encoding, sizeof(g_encoding_music)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); -} - - -int ucs2check(ucs2conv_t* conv) -{ int i = 0; iconv_t cd; const static char *charsets[] = { @@ -142,6 +127,21 @@ return 0; } +int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +{ + strncpy(g_encoding, encoding, sizeof(g_encoding)); + strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); + return ucs2check(conv); +} + +int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv) +{ + strncpy(g_encoding_music, encoding, sizeof(g_encoding_music)); + strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); + return ucs2check(conv); +} + + void ucs2big2little(ucs2char_t* value) { if (is_bigendian()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-06 04:39:10
|
Revision: 298 http://svn.sourceforge.net/pmplib/?rev=298&view=rev Author: nyaochi Date: 2007-02-05 20:39:09 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Make POSIX code build. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/lib/pmp/pmp_posix.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-06 04:06:42 UTC (rev 297) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-06 04:39:09 UTC (rev 298) @@ -170,24 +170,11 @@ int set_encoding(const char *encoding) { - ucs2conv_t conv; - - if (ucs2set_encoding(encoding, &conv) != 0) { - fprintf(stderr, "ERROR: iconv does not support the following conversion\n %s: from %s to %s\n", encoding, conv.from, conv.to); + if (ucs2setenc(encoding) != 0) { + fprintf(stderr, "ERROR: iconv does not support %s\n", encoding); return 1; } } - -int set_encoding_music(const char *encoding) -{ - ucs2conv_t conv; - - if (ucs2set_encoding_music(encoding, &conv) != 0) { - fprintf(stderr, "ERROR: iconv does not support the following conversion\n %s: from %s to %s\n", encoding, conv.from, conv.to); - return 1; - } -} - #endif int main(int argc, char *argv[]) @@ -227,9 +214,6 @@ if (opt.system_encoding) { set_encoding(opt.system_encoding); } - if (opt.music_encoding) { - set_encoding_music(opt.music_encoding); - } #endif/*_WIN32*/ // Set words to be stripped from artist names. Modified: trunk/pmplib/lib/pmp/pmp_posix.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-06 04:06:42 UTC (rev 297) +++ trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-06 04:39:09 UTC (rev 298) @@ -36,12 +36,11 @@ #include <filepath.h> #include <pmp.h> -#include <pmphelp.h> -typedef struct { +struct tag_pmplib_t { uint32_t num_plugins; lt_dlhandle *plugins; -} pmphelp_posix_t; +}; uint32_t interlocked_increment(uint32_t* count) { @@ -53,77 +52,75 @@ return --(*count); } -result_t pmphelp_init(pmphelp_t** ptr_pmphelp) +result_t pmplib_init(pmplib_t** ptr_pmplib) { lt_dlhandle inst = 0; - pmphelp_posix_t* pmphelp = NULL; + pmplib_t* pmplib = NULL; - pmphelp = (pmphelp_posix_t*)calloc(1, sizeof(pmphelp_posix_t)); - pmphelp->num_plugins = 0; - pmphelp->plugins = NULL; + pmplib = (pmplib_t*)calloc(1, sizeof(pmplib_t)); + pmplib->num_plugins = 0; + pmplib->plugins = NULL; lt_dlinit(); lt_dlsetsearchpath(PMP_MODULES_DIR); inst = lt_dlopenext("portalplayer1"); if (inst) { - pmphelp->num_plugins++; - pmphelp->plugins = (lt_dlhandle*)realloc(pmphelp->plugins, sizeof(lt_dlhandle) * pmphelp->num_plugins); - pmphelp->plugins[pmphelp->num_plugins-1] = inst; + pmplib->num_plugins++; + pmplib->plugins = (lt_dlhandle*)realloc(pmplib->plugins, sizeof(lt_dlhandle) * pmplib->num_plugins); + pmplib->plugins[pmplib->num_plugins-1] = inst; } else { fprintf(stderr, "FAILED: portalplayer1 in %s\n", PMP_MODULES_DIR); } inst = lt_dlopenext("iriverplus2"); if (inst) { - pmphelp->num_plugins++; - pmphelp->plugins = (lt_dlhandle*)realloc(pmphelp->plugins, sizeof(lt_dlhandle) * pmphelp->num_plugins); - pmphelp->plugins[pmphelp->num_plugins-1] = inst; + pmplib->num_plugins++; + pmplib->plugins = (lt_dlhandle*)realloc(pmplib->plugins, sizeof(lt_dlhandle) * pmplib->num_plugins); + pmplib->plugins[pmplib->num_plugins-1] = inst; } else { fprintf(stderr, "FAILED: iriverplus2\n"); } inst = lt_dlopenext("iriverplus3"); if (inst) { - pmphelp->num_plugins++; - pmphelp->plugins = (lt_dlhandle*)realloc(pmphelp->plugins, sizeof(lt_dlhandle) * pmphelp->num_plugins); - pmphelp->plugins[pmphelp->num_plugins-1] = inst; + pmplib->num_plugins++; + pmplib->plugins = (lt_dlhandle*)realloc(pmplib->plugins, sizeof(lt_dlhandle) * pmplib->num_plugins); + pmplib->plugins[pmplib->num_plugins-1] = inst; } else { fprintf(stderr, "FAILED: iriverplus3\n"); } inst = lt_dlopenext("irivnavi"); if (inst) { - pmphelp->num_plugins++; - pmphelp->plugins = (lt_dlhandle*)realloc(pmphelp->plugins, sizeof(lt_dlhandle) * pmphelp->num_plugins); - pmphelp->plugins[pmphelp->num_plugins-1] = inst; + pmplib->num_plugins++; + pmplib->plugins = (lt_dlhandle*)realloc(pmplib->plugins, sizeof(lt_dlhandle) * pmplib->num_plugins); + pmplib->plugins[pmplib->num_plugins-1] = inst; } else { fprintf(stderr, "FAILED: irivnavi\n"); } - *ptr_pmphelp = pmphelp; + *ptr_pmplib = pmplib; return 0; } -result_t pmphelp_finish(pmphelp_t* pmphelp) +result_t pmplib_finish(pmplib_t* pmplib) { - pmphelp_posix_t* pmphelpposix = (pmphelp_posix_t*)pmphelp; uint32_t i; - for (i = 0;i < pmphelpposix->num_plugins;++i) { - lt_dlclose(pmphelpposix->plugins[i]); + for (i = 0;i < pmplib->num_plugins;++i) { + lt_dlclose(pmplib->plugins[i]); } - free(pmphelpposix->plugins); - free(pmphelpposix); + free(pmplib->plugins); + free(pmplib); return 0; } -result_t pmphelp_enumerate_devid(pmphelp_t* pmphelp, pmp_enumerate_devid_callback_t callback, void *instance) +result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmplib_enumerate_devid_callback_t callback, void *instance) { - pmphelp_posix_t* pmphelpposix = (pmphelp_posix_t*)pmphelp; uint32_t i; - for (i = 0;i < pmphelpposix->num_plugins;++i) { - pmp_enumerate_devid_t func = (pmp_enumerate_devid_t)lt_dlsym(pmphelpposix->plugins[i], "pmp_enumerate_devid"); + for (i = 0;i < pmplib->num_plugins;++i) { + pmplib_enumerate_devid_t func = (pmplib_enumerate_devid_t)lt_dlsym(pmplib->plugins[i], "pmplib_enumerate_devid"); if (func) { func(callback, instance); } @@ -131,14 +128,13 @@ return 0; } -result_t pmphelp_create(pmphelp_t* pmphelp, pmp_t** pmp, const ucs2char_t* path_to_device, const char *id) +result_t pmplib_create(pmplib_t* pmplib, pmp_t** pmp, const ucs2char_t* path_to_device, const char *id) { - pmphelp_posix_t* pmphelpposix = (pmphelp_posix_t*)pmphelp; result_t ret = PMP_DEVICENOTFOUND; uint32_t i; - for (i = 0;i < pmphelpposix->num_plugins;++i) { - pmp_create_t func = (pmp_create_t)lt_dlsym(pmphelpposix->plugins[i], "pmp_create"); + for (i = 0;i < pmplib->num_plugins;++i) { + pmplib_create_t func = (pmplib_create_t)lt_dlsym(pmplib->plugins[i], "pmplib_create"); if (func) { ret = func(pmp, path_to_device, id); if (ret != PMP_DEVICENOTFOUND) { Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-06 04:06:42 UTC (rev 297) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-06 04:39:09 UTC (rev 298) @@ -74,7 +74,7 @@ encoding = nl_langinfo(CODESET); } #endif - return encoding ? strdup(encoding) : strdup("UTF-8"); + return encoding ? strdup(encoding) : strdup(MBS_CHARSET); } static void print_ucs2(const ucs2char_t* str) @@ -86,6 +86,13 @@ fprintf(stderr, "\n"); } +static int is_bigendian(void) +{ + ucs2char_t c = 0x1234; + uint8_t* p = (uint8_t*)&c; + return (*p == 0x12); +} + static const char *get_ucs2encoding(void) { static const char *unicode_big = "UNICODEBIG"; @@ -95,10 +102,7 @@ int ucs2init() { - if (!encoding) { - encoding = MBS_CHARSET; - } - strcpy(g_encoding, encoding); + strcpy(g_encoding, MBS_CHARSET); } static int ucs2check(ucs2conv_t* conv) @@ -108,8 +112,6 @@ const static char *charsets[] = { g_encoding, "UNICODE", "UNICODE", g_encoding, - g_encoding_music, "UNICODE", - "UNICODE", g_encoding_music, "UNICODE", "UTF-8", NULL, NULL, }; @@ -145,6 +147,10 @@ return ucs2check(&conv); } +const char *ucs2getenc() +{ + return g_encoding; +} int ucs2toi(const ucs2char_t* str) { @@ -203,9 +209,9 @@ return ret; } -size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size) +size_t mbstoucs2_charset(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size, const char *charset) { - iconv_t cd = iconv_open(g_ucs2encoding, g_encoding_music); + iconv_t cd = iconv_open(g_ucs2encoding, charset); size_t ret = iconv_convert(cd, (char **)&ucs2str, ucs_size * sizeof(ucs2char_t), (char **)&mbstr, mbs_size); iconv_close(cd); return ret; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-06 05:27:46
|
Revision: 299 http://svn.sourceforge.net/pmplib/?rev=299&view=rev Author: nyaochi Date: 2007-02-05 21:27:45 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Merge libpmpucs2 and libpmpfilepath into libpmp. Modified Paths: -------------- trunk/pmplib/Makefile.am trunk/pmplib/configure.in trunk/pmplib/frontend/easypmp/cui/Makefile.am trunk/pmplib/lib/filepath/Makefile.am trunk/pmplib/lib/gmi/Makefile.am trunk/pmplib/lib/playlist/Makefile.am trunk/pmplib/lib/pmp/Makefile.am trunk/pmplib/lib/pmp_iriverplus2/Makefile.am trunk/pmplib/lib/pmp_iriverplus3/Makefile.am trunk/pmplib/lib/pmp_irivnavi/Makefile.am trunk/pmplib/lib/pmp_portalplayer1/Makefile.am trunk/pmplib/lib/ucs2/Makefile.am Modified: trunk/pmplib/Makefile.am =================================================================== --- trunk/pmplib/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -1,6 +1,6 @@ # $Id$ -SUBDIRS = m4 libltdl lib/ucs2 lib/filepath lib/gmi lib/playlist lib/pmp lib/pmp_irivnavi lib/pmp_portalplayer1 lib/pmp_iriverplus2 lib/pmp_iriverplus3 frontend/easypmp/cui +SUBDIRS = m4 libltdl lib/ucs2 lib/filepath lib/pmp lib/gmi lib/playlist lib/pmp_irivnavi lib/pmp_portalplayer1 lib/pmp_iriverplus2 lib/pmp_iriverplus3 frontend/easypmp/cui docdir = $(prefix)/share/doc/@PACKAGE@ doc_DATA = README INSTALL COPYING AUTHORS ChangeLog Modified: trunk/pmplib/configure.in =================================================================== --- trunk/pmplib/configure.in 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/configure.in 2007-02-06 05:27:45 UTC (rev 299) @@ -228,7 +228,7 @@ dnl ------------------------------------------------------------------ dnl Output the configure results. dnl ------------------------------------------------------------------ -AC_CONFIG_FILES(Makefile m4/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/gmi/Makefile lib/pmp/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile) +AC_CONFIG_FILES(Makefile m4/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/pmp/Makefile lib/gmi/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile) if test -n "$JS_CFLAGS" ; then AC_DEFINE([HAVE_JSAPI_H], 1, [Define if you have the jsapi.h header]) Modified: trunk/pmplib/frontend/easypmp/cui/Makefile.am =================================================================== --- trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -33,8 +33,6 @@ easypmp_CFLAGS = -DPMP_JSPL_DIR="\"$(prefix)/share/@PACKAGE@/jspl\"" easypmp_LDADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ + $(top_builddir)/lib/pmp/libpmp.la \ $(top_builddir)/lib/gmi/libpmpgmi.la \ - $(top_builddir)/lib/playlist/libpmpplaylist.la \ - $(top_builddir)/lib/pmp/libpmp.la + $(top_builddir)/lib/playlist/libpmpplaylist.la Modified: trunk/pmplib/lib/filepath/Makefile.am =================================================================== --- trunk/pmplib/lib/filepath/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/filepath/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -1,16 +1,12 @@ # $Id$ -lib_LTLIBRARIES = libpmpfilepath.la +noinst_LTLIBRARIES = libfilepath.la -libpmpfilepath_la_SOURCES = \ +libfilepath_la_SOURCES = \ ../../include/filepath.h \ filepath_posix.c \ rel2abs.h \ rel2abs.c -libpmpfilepath_la_LDFLAGS = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - -no-undefined - AM_CFLAGS = @CFLAGS@ INCLUDES = @INCLUDES@ Modified: trunk/pmplib/lib/gmi/Makefile.am =================================================================== --- trunk/pmplib/lib/gmi/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/gmi/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -12,8 +12,7 @@ libpmpgmi_la_LDFLAGS = \ @ID3TAG_LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @VORBISFILE_LIBS@ \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ + $(top_builddir)/lib/pmp/libpmp.la \ -no-undefined AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/playlist/Makefile.am =================================================================== --- trunk/pmplib/lib/playlist/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/playlist/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -27,8 +27,7 @@ -no-undefined libpmpplaylist_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ + $(top_builddir)/lib/pmp/libpmp.la \ $(JS_LIBS) EXTRA_DIST = \ Modified: trunk/pmplib/lib/pmp/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/pmp/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -13,8 +13,8 @@ -no-undefined libpmp_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ + $(top_builddir)/lib/ucs2/libucs2.la \ + $(top_builddir)/lib/filepath/libfilepath.la \ $(LIBLTDL) EXTRA_DIST = pmp_plugin.sym Modified: trunk/pmplib/lib/pmp_iriverplus2/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/pmp_iriverplus2/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -28,8 +28,6 @@ -export-symbols $(top_srcdir)/lib/pmp/pmp_plugin.sym iriverplus2_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ $(top_builddir)/lib/pmp/libpmp.la AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/pmp_iriverplus3/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/pmp_iriverplus3/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -24,8 +24,6 @@ -export-symbols $(top_srcdir)/lib/pmp/pmp_plugin.sym iriverplus3_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ $(top_builddir)/lib/pmp/libpmp.la AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/pmp_irivnavi/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/pmp_irivnavi/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -18,8 +18,6 @@ -export-symbols $(top_srcdir)/lib/pmp/pmp_plugin.sym irivnavi_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ $(top_builddir)/lib/pmp/libpmp.la AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/pmp_portalplayer1/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -34,8 +34,6 @@ -export-symbols $(top_srcdir)/lib/pmp/pmp_plugin.sym portalplayer1_la_LIBADD = \ - $(top_builddir)/lib/ucs2/libpmpucs2.la \ - $(top_builddir)/lib/filepath/libpmpfilepath.la \ $(top_builddir)/lib/pmp/libpmp.la AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/ucs2/Makefile.am =================================================================== --- trunk/pmplib/lib/ucs2/Makefile.am 2007-02-06 04:39:09 UTC (rev 298) +++ trunk/pmplib/lib/ucs2/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) @@ -1,13 +1,13 @@ # $Id$ -lib_LTLIBRARIES = libpmpucs2.la +noinst_LTLIBRARIES = libucs2.la -libpmpucs2_la_SOURCES = \ +libucs2_la_SOURCES = \ ../../include/ucs2char.h \ ucs2char.c \ ucs2char_iconv.c -libpmpucs2_la_LDFLAGS = @ICONV_LIBS@ @LIBICONV@ -no-undefined +libucs2_la_LDFLAGS = @ICONV_LIBS@ @LIBICONV@ -no-undefined AM_CFLAGS = @CFLAGS@ INCLUDES = @INCLUDES@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-06 05:40:10
|
Revision: 300 http://svn.sourceforge.net/pmplib/?rev=300&view=rev Author: nyaochi Date: 2007-02-05 21:40:09 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Removed libpmpplaylist and libpmpgmi; they are now linked statically with the CUI program. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/Makefile.am trunk/pmplib/lib/gmi/Makefile.am trunk/pmplib/lib/playlist/Makefile.am Modified: trunk/pmplib/frontend/easypmp/cui/Makefile.am =================================================================== --- trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) +++ trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-06 05:40:09 UTC (rev 300) @@ -34,5 +34,5 @@ easypmp_LDADD = \ $(top_builddir)/lib/pmp/libpmp.la \ - $(top_builddir)/lib/gmi/libpmpgmi.la \ - $(top_builddir)/lib/playlist/libpmpplaylist.la + $(top_builddir)/lib/gmi/libgmi.la \ + $(top_builddir)/lib/playlist/libplaylist.la Modified: trunk/pmplib/lib/gmi/Makefile.am =================================================================== --- trunk/pmplib/lib/gmi/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) +++ trunk/pmplib/lib/gmi/Makefile.am 2007-02-06 05:40:09 UTC (rev 300) @@ -1,8 +1,8 @@ # $Id$ -lib_LTLIBRARIES = libpmpgmi.la +noinst_LTLIBRARIES = libgmi.la -libpmpgmi_la_SOURCES = \ +libgmi_la_SOURCES = \ ../../include/gmi.h \ gmi_mp3.c \ gmi_wma.c \ @@ -10,9 +10,8 @@ gmi_vorbis.c \ gmi.c -libpmpgmi_la_LDFLAGS = \ +libgmi_la_LDFLAGS = \ @ID3TAG_LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @VORBISFILE_LIBS@ \ - $(top_builddir)/lib/pmp/libpmp.la \ -no-undefined AM_CFLAGS = @CFLAGS@ Modified: trunk/pmplib/lib/playlist/Makefile.am =================================================================== --- trunk/pmplib/lib/playlist/Makefile.am 2007-02-06 05:27:45 UTC (rev 299) +++ trunk/pmplib/lib/playlist/Makefile.am 2007-02-06 05:40:09 UTC (rev 300) @@ -12,22 +12,21 @@ jspl_DATA = $(jspl_files) endif -lib_LTLIBRARIES = libpmpplaylist.la +noinst_LTLIBRARIES = libplaylist.la -libpmpplaylist_la_SOURCES = \ +libplaylist_la_SOURCES = \ ../../include/playlist.h \ rw_m3u.c \ rw_pls.c \ playlist.c \ $(jspl_c) -libpmpplaylist_la_CPPFLAGS = $(JS_CFLAGS) -DJS_THREADSAFE +libplaylist_la_CPPFLAGS = $(JS_CFLAGS) -DJS_THREADSAFE -libpmpplaylist_la_LDFLAGS = \ +libplaylist_la_LDFLAGS = \ -no-undefined -libpmpplaylist_la_LIBADD = \ - $(top_builddir)/lib/pmp/libpmp.la \ +libplaylist_la_LIBADD = \ $(JS_LIBS) EXTRA_DIST = \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-06 12:09:59
|
Revision: 301 http://svn.sourceforge.net/pmplib/?rev=301&view=rev Author: nyaochi Date: 2007-02-06 04:09:59 -0800 (Tue, 06 Feb 2007) Log Message: ----------- Incremental commit for POSIX build. There're still some bugs in pmp_iriverplus2. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/lib/pmp/pmp_posix.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-02-06 05:40:09 UTC (rev 300) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-02-06 12:09:59 UTC (rev 301) @@ -207,7 +207,6 @@ opt->num_strip_words ) == 0) { ++num_obtained; - } else { } record->ts_update = timestamp; record->ts_import = ts_import; Modified: trunk/pmplib/lib/pmp/pmp_posix.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-06 05:40:09 UTC (rev 300) +++ trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-06 12:09:59 UTC (rev 301) @@ -42,12 +42,12 @@ lt_dlhandle *plugins; }; -uint32_t interlocked_increment(uint32_t* count) +uint32_t pmplib_interlocked_increment(uint32_t* count) { return ++(*count); } -uint32_t interlocked_decrement(uint32_t* count) +uint32_t pmplib_interlocked_decrement(uint32_t* count) { return --(*count); } @@ -120,7 +120,7 @@ { uint32_t i; for (i = 0;i < pmplib->num_plugins;++i) { - pmplib_enumerate_devid_t func = (pmplib_enumerate_devid_t)lt_dlsym(pmplib->plugins[i], "pmplib_enumerate_devid"); + pmplib_enumerate_devid_t func = (pmplib_enumerate_devid_t)lt_dlsym(pmplib->plugins[i], "pmp_enumerate_devid"); if (func) { func(callback, instance); } @@ -134,7 +134,7 @@ uint32_t i; for (i = 0;i < pmplib->num_plugins;++i) { - pmplib_create_t func = (pmplib_create_t)lt_dlsym(pmplib->plugins[i], "pmplib_create"); + pmplib_create_t func = (pmplib_create_t)lt_dlsym(pmplib->plugins[i], "pmp_create"); if (func) { ret = func(pmp, path_to_device, id); if (ret != PMP_DEVICENOTFOUND) { Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-06 05:40:09 UTC (rev 300) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-06 12:09:59 UTC (rev 301) @@ -165,6 +165,7 @@ ip2db_record_t* ip2db_records = NULL; static const ucs2char_t ucs2cs_unknown[] = {'u','n','k','n','o','w','n',0}; + fprintf(stdout, "records = %d, num_records = %d\n", records, num_records); // Count valid entries. for (i = 0;i < num_records;++i) { if (ip2db_is_supported_codec(records[i].codec)) { @@ -236,10 +237,12 @@ idxheader_setget_unknown2(db->idx_buffer, &n, 1); // Free the allocated memory block. - for (i = 0;i < num_records;++i) { - ip2db_free_record(&ip2db_records[i]); + if (ip2db_records) { + for (i = 0;i < num_records;++i) { + ip2db_free_record(&ip2db_records[i]); + } + free(ip2db_records); } - free(ip2db_records); return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-07 14:12:59
|
Revision: 306 http://svn.sourceforge.net/pmplib/?rev=306&view=rev Author: nyaochi Date: 2007-02-07 06:11:15 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Do not use id3_file_open_fd() since it leaks file objects in Win32 environment. Use id3_file_open() instead even though this may lose some information in filenames during UCS-2 -> MBS conversion. Modified Paths: -------------- trunk/pmplib/lib/gmi/gmi_mp3.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/pmp.sln Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2007-02-07 12:33:41 UTC (rev 305) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2007-02-07 14:11:15 UTC (rev 306) @@ -333,18 +333,12 @@ ucs2char_t* ucs2 = NULL; struct id3_file *id3file = NULL; struct id3_tag *id3tag = NULL; - FILE *fp = NULL; + char *mbs_filename = ucs2dupmbs(filename); - /* Open the file with UNICODE filename. This is for better compatibility. */ - fp = ucs2fopen(filename, "rb"); - if (!fp) { - return -1; - } - /* Open with libid3tag */ - id3file = id3_file_fdopen(fileno(fp), ID3_FILE_MODE_READONLY); + id3file = id3_file_open(mbs_filename, ID3_FILE_MODE_READONLY); + ucs2free(mbs_filename); if (!id3file) { - fclose(fp); return -1; } Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-07 12:33:41 UTC (rev 305) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-07 14:11:15 UTC (rev 306) @@ -165,7 +165,6 @@ ip2db_record_t* ip2db_records = NULL; static const ucs2char_t ucs2cs_unknown[] = {'u','n','k','n','o','w','n',0}; - fprintf(stdout, "records = %d, num_records = %d\n", records, num_records); // Count valid entries. for (i = 0;i < num_records;++i) { if (ip2db_is_supported_codec(records[i].codec)) { Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-07 12:33:41 UTC (rev 305) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-07 14:11:15 UTC (rev 306) @@ -71,7 +71,7 @@ "System\\E10.SYS", "System\\db.dat", "System\\db.dic", "System\\db.idx", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "", "Playlists\\", + "System", "", "Playlists", ".plp", }, { Modified: trunk/pmplib/pmp.sln =================================================================== --- trunk/pmplib/pmp.sln 2007-02-07 12:33:41 UTC (rev 305) +++ trunk/pmplib/pmp.sln 2007-02-07 14:11:15 UTC (rev 306) @@ -14,8 +14,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp", "lib\pmp\pmp.vcproj", "{8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A}" ProjectSection(ProjectDependencies) = postProject + {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} {AA8DA82B-C209-4ABE-ABA1-22352962426D} = {AA8DA82B-C209-4ABE-ABA1-22352962426D} - {FA6E7B73-7CF8-47DD-A016-77382A1FD904} = {FA6E7B73-7CF8-47DD-A016-77382A1FD904} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_irivnavi", "lib\pmp_irivnavi\pmp_irivnavi.vcproj", "{2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1}" @@ -35,18 +35,18 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "easypmp_cui", "frontend\easypmp\cui\easypmp_cui.vcproj", "{FA1F30D4-6100-4379-8506-6CFE023B0AE7}" ProjectSection(ProjectDependencies) = postProject + {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} + {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} - {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} - {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "easypmp_win32gui", "frontend\easypmp\win32gui\easypmp_win32gui.vcproj", "{45CCFC7B-42B4-4FF9-AF43-FC3626B1672F}" ProjectSection(ProjectDependencies) = postProject + {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} + {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} + {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} + {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} - {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} - {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} - {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} - {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_portalplayer1", "lib\pmp_portalplayer1\pmp_portalplayer1.vcproj", "{544769C2-6989-452F-B626-E442CAC6553B}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-08 04:58:34
|
Revision: 308 http://svn.sourceforge.net/pmplib/?rev=308&view=rev Author: nyaochi Date: 2007-02-07 20:58:30 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Removed tailing '\\' character in path names. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/enumerate.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/frontend/easypmp/common/enumerate.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-02-07 15:50:54 UTC (rev 307) +++ trunk/pmplib/frontend/easypmp/common/enumerate.c 2007-02-08 04:58:30 UTC (rev 308) @@ -106,6 +106,7 @@ // Decode the music path prefix for system path separators filepath_combinepath(music_path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_music); + filepath_addslash(music_path); filepath_decode(music_path); fl->num_elements = 0; @@ -188,6 +189,7 @@ // Decode the playlist path prefix for system path separators filepath_combinepath(path, MAX_PATH, pmp->info.path_to_root, pmp->info.path_to_playlist); + filepath_addslash(path); filepath_decode(path); ret = find_file( path, Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-07 15:50:54 UTC (rev 307) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-08 04:58:30 UTC (rev 308) @@ -69,7 +69,7 @@ "System\\H10_Jr.SYS", "System\\H10_Jr.DAT", "System\\H10_Jr.IDX", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".plp", }, { @@ -78,7 +78,7 @@ "System\\U10.SYS", "System\\U10.dat", "System\\U10.idx", ".mp3\0.ogg\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".plp", }, { Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-07 15:50:54 UTC (rev 307) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-08 04:58:30 UTC (rev 308) @@ -52,9 +52,9 @@ }; static const ucs2char_t ucs2cs_music_path[] = - {'M','u','s','i','c',PATHCHAR,0}; + {'M','u','s','i','c',0}; static const ucs2char_t ucs2cs_playlist_path[] = - {'P','l','a','y','l','i','s','t','s',PATHCHAR,0}; + {'P','l','a','y','l','i','s','t','s',0}; static const ucs2char_t ucs2cs_playlist_ext[] = {'.','m','3','u',0}; static const ucs2char_t ucs2cs_irivnavi_idb[] = Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-07 15:50:54 UTC (rev 307) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-08 04:58:30 UTC (rev 308) @@ -73,7 +73,7 @@ "System\\H10.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Media\\Music\\", "Media\\Playlist\\", + "System", "Media\\Music", "Media\\Playlist", ".plp", hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, @@ -84,7 +84,7 @@ "System\\H10_5GP.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Media\\Music\\", "Media\\Playlist\\", + "System", "Media\\Music", "Media\\Playlist", ".plp", hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, @@ -95,7 +95,7 @@ "System\\H10.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, @@ -106,7 +106,7 @@ "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, @@ -117,7 +117,7 @@ "System\\H10.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, @@ -128,7 +128,7 @@ "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, @@ -139,7 +139,7 @@ "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_20gb_mtp_0100_0102, iriver_h10_parse_model }, @@ -150,7 +150,7 @@ "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", ".mp3\0.wma\0.wav\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, PMPCODEC_WAV, 0, 0, 0, 0}, - "System\\", "Music\\", "Playlists\\", + "System", "Music", "Playlists", ".pla", hdr_init_h10_20gb_mtp_0251, iriver_h10_parse_model }, @@ -161,7 +161,7 @@ "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "SYSTEM\\", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", + "SYSTEM", "MyJukeBox\\MUSIC", "MyJukeBox\\Playlist", ".pla", hdr_init_medion_mdjuke220, medion_mdjuke220_parse_model }, @@ -172,7 +172,7 @@ "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "SYSTEM\\", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", + "SYSTEM", "MyJukeBox\\MUSIC", "MyJukeBox\\Playlist", ".pla", hdr_init_medion_mdjuke440, medion_mdjuke220_parse_model }, @@ -183,7 +183,7 @@ "SYSTEM\\FW_YH820.mi4", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "System\\", "System\\MUSIC\\", "System\\PLAYLIST\\", + "System", "System\\MUSIC", "System\\PLAYLIST", ".plp", hdr_init_samsung_yh820, samsung_parse_model }, @@ -194,7 +194,7 @@ "SYSTEM\\FW_YH920.mi4", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "System\\", "System\\MUSIC\\", "System\\PLAYLIST\\", + "System", "System\\MUSIC", "System\\PLAYLIST", ".plp", hdr_init_samsung_yh920, samsung_parse_model }, @@ -205,7 +205,7 @@ "SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "System\\", "System\\MUSIC\\", "System\\PLAYLIST\\", + "System", "System\\MUSIC", "System\\PLAYLIST", ".plp", hdr_init_samsung_yh925, samsung_parse_model }, @@ -216,7 +216,7 @@ "SYSTEM\\FWImage.ebn", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "SYSTEM\\", "Music\\", "Playlists\\", + "SYSTEM", "Music", "Playlists", ".pla", hdr_init_philips_hdd6320, philips_hdd6320_parse_model }, @@ -227,7 +227,7 @@ "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, - "SYSTEM\\", "MUSIC\\", "Playlists\\", + "SYSTEM", "MUSIC", "Playlists", ".pla", hdr_init_msi_megaplayer540, megaplayer_parse_model }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-08 14:19:28
|
Revision: 309 http://svn.sourceforge.net/pmplib/?rev=309&view=rev Author: nyaochi Date: 2007-02-08 06:19:22 -0800 (Thu, 08 Feb 2007) Log Message: ----------- The completion of the initial documentation of the UCS-2 library. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char_iconv.c trunk/pmplib/lib/ucs2/ucs2char_win32.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/include/ucs2char.h 2007-02-08 14:19:22 UTC (rev 309) @@ -344,10 +344,39 @@ * @{ */ +/** + * Test whether a USC-2 character is a surrogate-pair character in UTF-16. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2issurrogate(ucs2char_t c); + +/** + * Test whether a USC-2 character is a whitespace character. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2isspace(ucs2char_t c); + +/** + * Test whether a USC-2 character is a numeric character. + * @param c The UCS-2 character to be tested. + * @retval int Non-zero value if the test is true, zero otherwise. + */ UCS2API int ucs2isdigit(ucs2char_t c); + +/** + * Convert a UCS-2 character to lower case. + * @param c The UCS-2 character to be coverted. + * @retval ucs2char_t The resultant UCS-2 character. + */ UCS2API ucs2char_t ucs2lower(ucs2char_t c); + +/** + * Convert a UCS-2 character to upper case. + * @param c The UCS-2 character to be coverted. + * @retval ucs2char_t The resultant UCS-2 character. + */ UCS2API ucs2char_t ucs2upper(ucs2char_t c); /** @@ -607,11 +636,42 @@ * @{ */ +/** + * Convert a UCS-2 string to integer value. + * @param str The pointer to a string. + * @retval int The corresponding integer value. + */ UCS2API int ucs2toi(const ucs2char_t* str); + +/** + * Convert an integer value to UCS-2 string. + * @param value The integer value. + * @param string The pointer to the buffer to receive the string. + * @param radix Radix of the \a value. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); -UCS2API ucs2char_t fputucs2c(ucs2char_t c, FILE *fp); + +/** + * Open a stream from a file. + * @param filename The pointer to the UCS-2 string for the file name. + * @param mode The pointer to the C string for the open mode. + * @retval FILE* The pointer to the opened stream if successful, + * NULL otherwise. + */ UCS2API FILE *ucs2fopen(const ucs2char_t *filename, const char *mode); +/** + * Write a UCS-2 character to a stream. + * @param c The character to be written. + * @param fp The pointer to the output stream. + * @retval int Zero if successful, non-zero otherwise. + */ +UCS2API int fputucs2c(ucs2char_t c, FILE *fp); + + + /** @} */ /** @} */ Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 14:19:22 UTC (rev 309) @@ -241,14 +241,16 @@ } } -ucs2char_t fputucs2c(ucs2char_t c, FILE *fp) +int fputucs2c(ucs2char_t c, FILE *fp) { ucs2char_t ucs2str[2] = {c, 0}; size_t mbs_size = ucs2tombs(NULL, 0, ucs2str, ucs2len(ucs2str)) + 1; char* mbs = (char *)alloca(mbs_size * sizeof(char)); if (mbs) { ucs2tombs(mbs, mbs_size, ucs2str, ucs2len(ucs2str)+1); - fputs(mbs, fp); + return (fputs(mbs, fp) != EOF : 0 ? 1); + } else { + return 1; } } Modified: trunk/pmplib/lib/ucs2/ucs2char_win32.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-08 04:58:30 UTC (rev 308) +++ trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-08 14:19:22 UTC (rev 309) @@ -105,9 +105,9 @@ } -ucs2char_t fputucs2c(ucs2char_t c, FILE *fp) +int fputucs2c(ucs2char_t c, FILE *fp) { - return (ucs2char_t)fputwc((wchar_t)c, fp); + return (fputwc((wchar_t)c, fp) != WEOF ? 0 : 1); } FILE *ucs2fopen(const ucs2char_t *filename, const char *mode) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-08 16:41:54
|
Revision: 310 http://svn.sourceforge.net/pmplib/?rev=310&view=rev Author: nyaochi Date: 2007-02-08 08:41:30 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Document filepath API. Modified Paths: -------------- trunk/pmplib/include/filepath.h trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/filepath/filepath_posix.c trunk/pmplib/lib/filepath/filepath_win32.c trunk/pmplib/lib/gmi/gmi.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus2/playlist.c trunk/pmplib/lib/pmp_iriverplus2/util.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_iriverplus3/util.c trunk/pmplib/lib/pmp_irivnavi/playlist.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/util.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/include/filepath.h =================================================================== --- trunk/pmplib/include/filepath.h 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/include/filepath.h 2007-02-08 16:41:30 UTC (rev 310) @@ -24,6 +24,7 @@ #ifndef __FILEPATHUTIL_H__ #define __FILEPATHUTIL_H__ +#include <time.h> #include <ucs2char.h> #ifdef FILEPATH_EXPORTS @@ -37,56 +38,306 @@ extern "C" { #endif/*__cplusplus*/ -typedef int (*filepath_findfile_callback)( - void *instance, - const ucs2char_t* found_path, - const ucs2char_t* found_file - ); +/** + * \addtogroup filepath File/Path Manupulation API + * @{ + * + * The PMPlib File/Path Manupulation API is a utility for file-systems and + * pathnames. + */ -FILEPATHAPI int find_file( - const ucs2char_t* path, - int recursive, - filepath_findfile_callback callback, - void *instance - ); +/** + * \addtogroup filepath_string file/path string API + * @{ + * + */ +/** + * Add a (back)slash character to the end of a string. + * + * This function adds a (back)slash character to the end of the string if + * the resultant string is grammertical. If the string already has a trailing + * (back)slash, this function will not change it. + * + * @param path The pointer to the string. + * @retval ucs2char_t* Identical value to \a path argument. + */ FILEPATHAPI ucs2char_t* filepath_addslash(ucs2char_t* path); + +/** + * Remove a (back)slash character from the end of a string. + * + * This function removes a (back)slash character from the end of the string if + * the resultant string is grammertical. If the string already has no trailing + * (back)slash, this function will not change it. + * + * @param path The pointer to the string. + * @retval ucs2char_t* The identical value to \a path argument. + */ FILEPATHAPI ucs2char_t* filepath_removeslash(ucs2char_t* path); -FILEPATHAPI int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext); - +/** + * Concatenate two strings into one well-formed path. + * + * @param dst The pointer to a buffer to receive the resultant path. + * @param size The size, in number of UCS-2 characters, of \a dst. + * @param path The pointer to a path name. + * @param file The pointer to a file name. + * @retval const ucs2char_t* The identical value to \a dst argument. + */ FILEPATHAPI const ucs2char_t* filepath_combinepath(ucs2char_t* dst, size_t size, const ucs2char_t* path, const ucs2char_t* file); +/** + * Remove the path portion of a filepath name. + * + * @param path The pointer to the filepath name from which this + * function removes the path portion. The resultant string + * will contain only the file portion. + */ FILEPATHAPI void filepath_strippath(ucs2char_t* path); -FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip the path portion in a filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips the path portion. The skipped string + * will contain only the file portion. + * @retval const ucs2char_t* The pointer at which the file portion begins. + */ FILEPATHAPI const ucs2char_t* filepath_skippath(const ucs2char_t* path); -FILEPATHAPI const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root); -FILEPATHAPI const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path); +/** + * Remove the file portion from a string. + * + * @param path The pointer to the string from which the file portion + * is removed. + */ +FILEPATHAPI void filepath_remove_filespec(ucs2char_t* path); + +/** + * Skip a portion in a filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips the portion. + * @param root The pointer to the string representing the portion to + * be skipped. + * @retval const ucs2char_t* The pointer at the next character after the + * portion \a root ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip a portion in filepath name, assuming it as the root directory. + * + * The resultant string will begin with a path character. + * + * @param path The pointer to the filepath name from which this + * function skips the portion. + * @param root The pointer to the string representing the portion to + * be skipped. + * @retval const ucs2char_t* The pointer at the next character after the + * portion \a root ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip a directory name in filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips a directory name. + * @retval const ucs2char_t* The pointer at the next character after the + * directory name ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path); + +/** + * Add a file extension to the end of a string. + * + * @param path The pointer to the string. + * @param ext The pointer to the file extension. + */ FILEPATHAPI void filepath_add_extension(ucs2char_t* path, const ucs2char_t* ext); + +/** + * Remove a file extension from the end of a string. + * + * @param path The pointer to the string from which the extension + * is removed. + */ FILEPATHAPI void filepath_remove_extension(ucs2char_t* path); -FILEPATHAPI void filepath_remove_filespec(ucs2char_t* path); -FILEPATHAPI void filepath_replace_slash(ucs2char_t* path, ucs2char_t c); -FILEPATHAPI int filepath_is_relative(const ucs2char_t* path); +/** + * Convert a relative path to its corresponding absolute path. + * + * @param absolute The pointer to a buffer to receive the resultant path. + * @param base The name of the base directory where the relative path + * begins. + * @param relative The relative path to be converted. + * @retval int Reserved (0). + */ FILEPATHAPI int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative); + +/** + * Canonicalize a path. + * + * @param dst The pointer to a buffer to receive the resultant path. + * @param src The path to be canonicalized. + * @retval Non-zero value if successful, zero otherwise. + */ FILEPATHAPI int filepath_path_canonicalize(ucs2char_t* dst, const ucs2char_t* src); + +/** + * Replaces all path separators with a backslash ('\') separator. + * + * This function replaces all path separators in the given path with + * Windows-style path separators (back-slashes). On POSIX systems, this means + * converting forward slash ('/') path separators into backslashes. On + * Windows, this is a no-op. The \p path is modified in place. + * + * @param path The pointer to the path string to be converted. + * @return int Reserved. + */ +FILEPATHAPI int filepath_encode(ucs2char_t* path); + +/** + * Replaces '\'-slashes in a path name with the native path separator. + * + * This function replaces all Windows-style path separators + * (back-slashes) in the given path with the native path separator. On + * POSIX systems, the replacement character is a forward slash ('/'). On + * Windows, this is a no-op. The \p path is modified in place. + * + * @param path The pointer to the path string to be converted. + * @return int Reserved. + */ +FILEPATHAPI int filepath_decode(ucs2char_t* path); + +/** @} */ + +/** + * \addtogroup filepath_filedir file/directory manupulation API + * @{ + * + */ + +/** + * Prototype for the callback function for receiving found files. + * + * @param instance The instance value. + * @param found_path The path-name portion of the found file. + * @param found_file The file-name portion of the found file. + * @retval int Reserved. + */ +typedef int (*filepath_findfile_callback)(void *instance, const ucs2char_t* found_path, const ucs2char_t* found_file); + +/** + * Find files. + * + * @param path The directory in which this function starts the search. + * @param recursive Non-zero value to search files recursively under the + * directory \p path. + * @param callback The pointer to the callback function to receive the + * names of found files. + * @param instance A user-defined instance value that will be sent to the + * callback function. + * @retval int Reserved. + */ +FILEPATHAPI int find_file(const ucs2char_t* path, int recursive, filepath_findfile_callback callback, void *instance); + +/** + * Test the existence of a file. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ FILEPATHAPI int filepath_file_exists(const ucs2char_t* path); + +/** + * Test a file name has an extension. + * + * @param filename The file name to be tested. + * @param ext The extension. + * @retval int True or false. + */ +FILEPATHAPI int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext); + +/** + * Test if a filepath name represents a directory. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ +FILEPATHAPI int filepath_is_dir(const ucs2char_t *path); + +/** + * Test if a filepath name represents a relative path. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ +FILEPATHAPI int filepath_is_relative(const ucs2char_t* path); + +/** + * Test if two path names has a common prefix of a directory. + * + * @param path1 A filepath name. + * @param path2 Another filepath name. + * @retval int True or false. + */ FILEPATHAPI int filepath_is_same_root(const ucs2char_t* path1, const ucs2char_t* path2); +/** + * Obtain the last-modified time of a file. + * + * @param filename The filepath name. + * @retval time_t The time stamp when the file was updated most recently. + */ +FILEPATHAPI time_t filepath_mtime(const ucs2char_t *filename); + +/** + * Compares the modification times of two files. + * + * This function compares the modification times of @p file1 and @p file2 + * and returns the difference between them is returned. + * + * @param file1 The name of file #1. + * @param file2 The name of file #2. + * @retval int The comparison result: + * - < 0, if file2 was modified more recently than file1; + * - = 0, if the modification times are the same; + * - > 0, if file1 was modified more recently than file2. + */ FILEPATHAPI int filepath_compare_lastupdate(const ucs2char_t* file1, const ucs2char_t* file2); +/** + * Obtain the size of a file. + * + * @param filename The filepath name. + * @retval uint32_t The size, in bytes, of the file. + */ +FILEPATHAPI uint32_t filepath_size(const ucs2char_t *filename); + +/** + * Remove a file. + * + * @param file The name of a file to be removed. + * @retval int True if succeeded, false otherwise. + */ FILEPATHAPI int filepath_removefile(const ucs2char_t* file); + +/** + * Copy a file. + * + * @param src The name of a source file to be copied. + * @param dst The name of a destination to be created. + * @retval int True if succeeded, false otherwise. + */ FILEPATHAPI int filepath_copyfile(const ucs2char_t* src, const ucs2char_t* dst); -FILEPATHAPI int filepath_encode(ucs2char_t* path); -FILEPATHAPI int filepath_decode(ucs2char_t* path); +/** @} */ -FILEPATHAPI time_t filepath_mtime(const ucs2char_t *filename); -FILEPATHAPI uint32_t filepath_size(const ucs2char_t *filename); -FILEPATHAPI int filepath_is_dir(const ucs2char_t *filename); -FILEPATHAPI int filepath_exist(const ucs2char_t *filename); +/** @} */ #ifdef __cplusplus } Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/include/ucs2char.h 2007-02-08 16:41:30 UTC (rev 310) @@ -25,7 +25,6 @@ #define __UCS2CHAR_H__ #include <stdio.h> -#include <time.h> #ifdef UCS2_EXPORTS #define UCS2API __declspec(dllexport) Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-08 16:41:30 UTC (rev 310) @@ -23,16 +23,6 @@ /* $Id$ */ -/** - * @file - * - * Functions for working with file and path names with different path - * separators (POSIX implementation). - * - * @addtogroup filepath - * @{ - */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif/*HAVE_CONFIG_H*/ @@ -113,22 +103,6 @@ return 0; } -/** - * Finds the file name extension in a native path name. - * - * Checks if the file name in the given @p path has a file name - * extension: that is, whether the part of the path after the last - * path separator contains a period ('.'). If the @p path has an - * extension a pointer to the first character after the last period - * is returned (or a pointer to the null terminator if there are no - * subsequent characters). If the file name has no extension, then - * null itself is returned. - * - * @param path the path name to be searched for an extension. - * - * @return a pointer to the file name extension, or NULL if none was - * found. - */ static ucs2char_t* search_extension(ucs2char_t* path) { ucs2char_t* p = ucs2rchr(path, PATHCHAR); @@ -141,18 +115,6 @@ return NULL; } -/** - * Adds the native path separator to a UCS-2 encoded path name. - * - * If the given @p path does not have a native path separator at the - * end, then one is added. The @p path is modified in place, and is - * assumed to have enough space allocated to it to add the extra - * character. - * - * @param path the path name to be modified. - * - * @return a pointer to the last character in the new path. - */ ucs2char_t* filepath_addslash(ucs2char_t* path) { size_t length = ucs2len(path); @@ -166,16 +128,6 @@ return (path + length); } -/** - * Removes the native path separator from a UCS-2 encoded path name. - * - * If the given @p path has a native path separator at then end, then - * it is removed (or more accurately, it is replaced with the null - * terminator). - * - * @param path the path name to be modified. - * @return a pointer to the last character in the new path. - */ ucs2char_t* filepath_removeslash(ucs2char_t* path) { size_t length = ucs2len(path)-1; @@ -186,15 +138,6 @@ return (path + length); } -/** - * Determines if a filename has a given extension (case-insensitive). - * - * - * @param filename file name to be checked. - * @param ext file name extension to check for. - * @return non-nil if the filename has the given extension, or nil - * otherwise. - */ int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext) { const ucs2char_t* p = search_extension((ucs2char_t*)filename); @@ -250,7 +193,7 @@ return p ? p+1 : path; } -const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root) +const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root) { const ucs2char_t* p = filepath_skiproot(path, root); if (p == NULL) p = path; @@ -260,7 +203,7 @@ return p; } -const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path) +const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path) { ucs2char_t* p = ucs2chr(path, PATHCHAR); return p ? p+1 : NULL; @@ -293,25 +236,6 @@ } } -/** - * Replace native path separators in a path with another character. - * - * The native path separators (i.e. '/' on POSIX-like systems) in the - * given @p path are replaced with the given character, @p c. The - * path is modified in place. - * @param path the path in which path separators are to be replaced. - * @param c the replacement character. - */ -void filepath_replace_slash(ucs2char_t* path, ucs2char_t c) -{ - while (*path) { - if (*path == PATHCHAR) { - *path = c; - } - path++; - } -} - void filepath_add_extension(ucs2char_t* path, const ucs2char_t* ext) { ucs2char_t* p = search_extension(path); @@ -336,25 +260,28 @@ } } -/** - * Tests whether a path name is relative. - * - * Checks whether the given @p path begins with a path separator - * character. If the path does begin with a path separator, then it - * is absolute and nil is returned. Otherwise the path is relative, - * and a non-nil value is returned. - * - * @param path the path to be tested for being relative. - * @return non-nil if the path name is relative, nil otherwise. - */ int filepath_is_relative(const ucs2char_t* path) { return (*path != PATHCHAR); } -int filepath_file_exists(const ucs2char_t* path) +int filepath_file_exists(const ucs2char_t *path) { - return filepath_exist(path); + int ret = 0; + struct stat st; + char *mbs_path = ucs2dupmbs(filename); + + if (mbs_path) { + path_decode(mbs_path); + //fprintf(stderr, "is_exist: %s\n", mbs_path); + ret = open(mbs_path, 0); + free(mbs_path); + if (ret != -1) { + close(ret); + } + return (ret != -1); + } + return 0; } int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative) @@ -362,34 +289,11 @@ return (rel2abs(relative, base, absolute, MAX_PATH) != NULL); } -/** - * Tests whether a path name has a given prefix. - * - * Tests whether the @p path name begins with the named @p root. If - * @p root names a directory with a trailing path separator, then this - * function is useful for checking whether a directory (or file) with - * the given @p path would be a sub-directory of (respectively, file - * located below) @p root. - * @param path the path name to be checked for a given prefix. - * @param root the prefix to check for. - * @return non-nil if the path name starts with the given @p root and - * nil otherwise. - */ int filepath_is_same_root(const ucs2char_t* path, const ucs2char_t* root) { return (ucs2ncmp(path, root, ucs2len(root)) == 0); } -/** - * Compares the modification times of two files. - * - * The modification times of @p file1 and @p file2 are compared, and - * the difference between them is returned. The result is: - * - < 0, if file2 was modified more recently than file1; - * - = 0, if the modification times are the same; - * - > 0, if file1 was modified more recently than file2. - * @return the difference in modification times between the two files. - */ int filepath_compare_lastupdate(const ucs2char_t* file1, const ucs2char_t* file2) { int ret = 0; @@ -430,20 +334,6 @@ return ret; } -/** - * Removes the named file. - * - * The given @p file name is converted to a multi-byte character - * string, which is used as an argument to the 'remove' function in - * the C library. Thus, if the @p file name refers to a file, then - * that file is unlinked. If it refers to a directory, and that - * directory is empty, then the directory is deleted. The value - * returned is the result of the calling remove, i.e. 0 on success, - * and -1 on error. The value of errno will be set in the case of an - * error. - * @param file the path name to be unlinked/deleted. - * @return 0 on success, -1 on error. - */ int filepath_removefile(const ucs2char_t* file) { int ret = 0; @@ -453,17 +343,6 @@ return ret; } -/** - * Replaces all path separators with a backslash ('\') separator. - * - * Replaces all path separators in the given path with Windows-style - * path separators (back-slashes). On POSIX systems, this means - * converting forward slash ('/') path separators into backslashes. On - * Windows, this is a no-op. The @p path is modified in place. - * - * @param path the path to be converted. - * @return - */ int filepath_encode(ucs2char_t* path) { while (*path) { @@ -475,17 +354,6 @@ return 0; } -/** - * Replaces '\'-slashes in a path name with the native path separator. - * - * Replaces all Windows-style path separators (back-slashes) in the - * given path with the native path separator. On POSIX systems, the - * replacement character is a forward slash ('/'). On Windows, this - * is a no-op. The @p path is modified in place. - * - * @param path the path to be converted. - * @return - */ int filepath_decode(ucs2char_t* path) { while (*path) { @@ -496,4 +364,3 @@ } return 0; } -/**@}*/ Modified: trunk/pmplib/lib/filepath/filepath_win32.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-08 16:41:30 UTC (rev 310) @@ -117,7 +117,7 @@ return p ? p+1 : path; } -const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root) +const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root) { const ucs2char_t* p = filepath_skiproot(path, root); if (p == NULL) p = path; @@ -127,22 +127,12 @@ return p; } -const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path) +const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path) { ucs2char_t* p = ucs2chr(path, '\\'); return p ? p+1 : NULL; } -void filepath_replace_slash(ucs2char_t* path, ucs2char_t c) -{ - while (*path) { - if (*path == '\\') { - *path = c; - } - path++; - } -} - void filepath_strippath(ucs2char_t* path) { PathStripPathW(path); Modified: trunk/pmplib/lib/gmi/gmi.c =================================================================== --- trunk/pmplib/lib/gmi/gmi.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/gmi/gmi.c 2007-02-08 16:41:30 UTC (rev 310) @@ -63,6 +63,17 @@ }; +static void replace_slash(ucs2char_t* path, ucs2char_t c) +{ + while (*path) { + if (*path == PATHCHAR) { + *path = c; + } + path++; + } +} + + static int gmi_get_from_pathname( media_info_t* info, const ucs2char_t *filename, @@ -102,28 +113,28 @@ /* Obtain genre, artist, and album values from the path if necessary. */ if (flag & GMIF_GENRE) { - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->genre = ucs2ndup(p, (q-p) - 1); p = q; - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->artist = ucs2ndup(p, (q-p) - 1); if (flag & GMIF_ALBUM) { info->album = ucs2dup(q); filepath_removeslash(info->album); - filepath_replace_slash(info->album, (ucs2char_t)' '); + replace_slash(info->album, (ucs2char_t)' '); } } } } else { - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->artist = ucs2ndup(p, (q-p) - 1); if (flag & GMIF_ALBUM) { info->album = ucs2dup(q); filepath_removeslash(info->album); - filepath_replace_slash(info->album, (ucs2char_t)' '); + replace_slash(info->album, (ucs2char_t)' '); } } } Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-08 16:41:30 UTC (rev 310) @@ -196,7 +196,7 @@ } dst->entry_number = j+1; - dst->pathname = ucs2dup(filepath_skipdrive(src->filename, path_to_root)); + dst->pathname = ucs2dup(filepath_changeroot(src->filename, path_to_root)); filepath_remove_filespec(dst->pathname); filepath_encode(dst->pathname); dst->filename = ucs2dup(filepath_skippath(src->filename)); Modified: trunk/pmplib/lib/pmp_iriverplus2/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-08 16:41:30 UTC (rev 310) @@ -58,7 +58,7 @@ filepath_decode(decoded_filename); // 2. As above, with mount point prefix stripped. - ucs2cpy(decoded_filepathname, filepath_skipdrive(decoded_filename, path_to_root)); + ucs2cpy(decoded_filepathname, filepath_changeroot(decoded_filename, path_to_root)); // 3. As above, but with filename stripped. ucs2cpy(decoded_pathname, decoded_filepathname); Modified: trunk/pmplib/lib/pmp_iriverplus2/util.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -31,6 +31,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include "util.h" Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-08 16:41:30 UTC (rev 310) @@ -569,7 +569,7 @@ ip3db_variant_t* dst = records[i]; ip3db_record_init(&pmpmi->ip3db, &records[i]); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_changeroot(src->filename, pmp->info.path_to_root)); filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); @@ -700,7 +700,7 @@ filepath_combinepath(filepath, MAX_PATH, rootdir, music->pmp->info.path_to_playlist); filepath_addslash(filepath); - dst->filepath = ucs2dup(filepath_skipdrive(filepath, music->pmp->info.path_to_root)); + dst->filepath = ucs2dup(filepath_changeroot(filepath, music->pmp->info.path_to_root)); filepath_slash(dst->filepath); dst->num_entries = src->num_entries; @@ -708,7 +708,7 @@ for (j = 0;j < src->num_entries;++j) { ucs2char_t filename[MAX_PATH]; - ucs2cpy(filename, filepath_skipdrive(src->entries[j], music->pmp->info.path_to_root)); + ucs2cpy(filename, filepath_changeroot(src->entries[j], music->pmp->info.path_to_root)); filepath_slash(filename); dst->entries[j] = ucs2dup(filename); } Modified: trunk/pmplib/lib/pmp_iriverplus3/util.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus3/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -28,6 +28,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include <malloc.h> Modified: trunk/pmplib/lib/pmp_irivnavi/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-08 16:41:30 UTC (rev 310) @@ -63,7 +63,7 @@ if (mediafiles[i][0]) { char *mbs = NULL; ucs2char_t filename[MAX_PATH]; - ucs2cpy(filename, filepath_skipdrive(mediafiles[i], path_to_root)); + ucs2cpy(filename, filepath_changeroot(mediafiles[i], path_to_root)); filepath_encode(filename); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-08 16:41:30 UTC (rev 310) @@ -474,7 +474,7 @@ // Set record fields. record_init(dst); - dst->filename = ucs2dupmbs(filepath_skipdrive(src->filename, music->pmp->info.path_to_root)); + dst->filename = ucs2dupmbs(filepath_changeroot(src->filename, music->pmp->info.path_to_root)); dst->title = src->title ? ucs2dupmbs(src->title) : ucs2dupmbs(filepath_skippath(src->filename));; dst->artist = ucs2dupmbs(src->artist ? src->artist : ucs2cs_unknown); dst->album = ucs2dupmbs(src->album ? src->album : ucs2cs_unknown); Modified: trunk/pmplib/lib/pmp_portalplayer1/util.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_portalplayer1/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -31,6 +31,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include "util.h" Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 16:41:30 UTC (rev 310) @@ -319,22 +319,3 @@ } return 0; } - -int filepath_exist(const ucs2char_t *filename) -{ - int ret = 0; - struct stat st; - char *mbs_path = ucs2dupmbs(filename); - - if (mbs_path) { - path_decode(mbs_path); - //fprintf(stderr, "is_exist: %s\n", mbs_path); - ret = open(mbs_path, 0); - free(mbs_path); - if (ret != -1) { - close(ret); - } - return (ret != -1); - } - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-08 17:31:21
|
Revision: 311 http://svn.sourceforge.net/pmplib/?rev=311&view=rev Author: nyaochi Date: 2007-02-08 09:31:14 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Sync the Win32 GUI with the latest API. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/win32gui/easypmp_win32gui.rc trunk/pmplib/frontend/easypmp/win32gui/maindlg.h trunk/pmplib/frontend/easypmp/win32gui/preference.h trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h trunk/pmplib/pmp.sln Modified: trunk/pmplib/frontend/easypmp/win32gui/easypmp_win32gui.rc =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/easypmp_win32gui.rc 2007-02-08 16:41:30 UTC (rev 310) +++ trunk/pmplib/frontend/easypmp/win32gui/easypmp_win32gui.rc 2007-02-08 17:31:14 UTC (rev 311) @@ -29,6 +29,20 @@ // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_DONE ICON "res\\checkmark.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +3 TEXTINCLUDE +BEGIN + "\r\n" +END + +#endif // APSTUDIO_INVOKED + #endif // \x93\xFA\x96{\x8C\xEA resources ///////////////////////////////////////////////////////////////////////////// @@ -78,54 +92,51 @@ // Dialog // -IDD_PREFERENCE DIALOGEX 0, 0, 263, 246 +IDD_PREFERENCE DIALOGEX 0, 0, 263, 234 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU CAPTION "EasyPMP [Win32 GUI]" FONT 8, "MS Shell Dlg", 400, 0, 0x80 BEGIN - DEFPUSHBUTTON "OK",IDOK,144,222,48,12 - PUSHBUTTON "Cancel",IDCANCEL,204,222,48,12 + DEFPUSHBUTTON "OK",IDOK,144,210,48,12 + PUSHBUTTON "Cancel",IDCANCEL,204,210,48,12 GROUPBOX "Media database",IDC_STATIC,12,12,240,48 CONTROL "&None",IDC_RADIO_DATABASE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,24,24,72,8 CONTROL "&Update",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,96,24,72,8 CONTROL "&Rebuild",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,168,24,72,8 LTEXT "Source of media information (&z):",IDC_STATIC,24,42,108,12 COMBOBOX IDC_COMBO_MEDIAINFO_SOURCE,138,42,102,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Playlist conversion",IDC_STATIC,12,66,240,72 + GROUPBOX "Playlist conversion",IDC_STATIC,12,66,240,60 CONTROL "N&one",IDC_RADIO_PLAYLIST,"Button",BS_AUTORADIOBUTTON | WS_GROUP,24,78,72,8 CONTROL "&Update",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON,96,78,72,8 CONTROL "Re&convert",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON,168,78,72,8 - LTEXT "Playlist folder(s):",IDC_STATIC,24,96,72,8 - CONTROL "&Music",IDC_CHECK_PL_MUSIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,96,72,8 - CONTROL "&Playlist",IDC_CHECK_PL_PLAYLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,96,72,8 - LTEXT "Conversion option:",IDC_STATIC,24,108,72,8 - CONTROL "&Find missing",IDC_CHECK_PL_FIND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,108,72,8 - CONTROL "&Skip missing",IDC_CHECK_PL_SKIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,108,72,8 - CONTROL "Use &JavaScript playlist",IDC_CHECK_PL_JSPL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,120,144,8 - GROUPBOX "Portable Player Device",IDC_STATIC,12,144,240,72 - LTEXT "&Location:",IDC_STATIC,24,156,42,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_DEVICE_LOCATION,78,156,42,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Sa&ve log",IDC_CHECK_SAVE_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,156,66,12 - LTEXT "&Identifier:",IDC_STATIC,24,174,42,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_DEVICE_ID,78,174,162,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - LTEXT "Description:",IDC_STATIC,24,192,42,12,SS_CENTERIMAGE - LTEXT "?X?^?e?B?b?N",IDC_STATIC_PLAYER_DESCRIPTION,78,192,162,12,0,WS_EX_CLIENTEDGE + LTEXT "Conversion option:",IDC_STATIC,24,96,72,8 + CONTROL "&Find missing",IDC_CHECK_PL_FIND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,96,72,8 + CONTROL "&Skip missing",IDC_CHECK_PL_SKIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,96,72,8 + CONTROL "Use &JavaScript playlist",IDC_CHECK_PL_JSPL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,108,144,8 + GROUPBOX "Portable Player Device",IDC_STATIC,12,132,240,72 + LTEXT "&Location:",IDC_STATIC,24,145,42,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_DEVICE_LOCATION,78,145,42,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Sa&ve log",IDC_CHECK_SAVE_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,145,66,12 + LTEXT "&Identifier:",IDC_STATIC,24,162,42,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_DEVICE_ID,78,162,162,36,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Description:",IDC_STATIC,24,180,42,12,SS_CENTERIMAGE + LTEXT "?X?^?e?B?b?N",IDC_STATIC_PLAYER_DESCRIPTION,78,180,162,12,0,WS_EX_CLIENTEDGE CONTROL "E&ject the player on completion",IDC_CHECK_SAFEREMOVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,222,120,12 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,210,120,12 END -IDD_PROCESSING DIALOGEX 0, 0, 263, 246 +IDD_PROCESSING DIALOGEX 0, 0, 263, 234 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU CAPTION "EasyPMP [Win32 GUI]" FONT 8, "MS Shell Dlg", 400, 0, 0x80 BEGIN - DEFPUSHBUTTON "OK",IDOK,144,222,48,12,NOT WS_VISIBLE - PUSHBUTTON "Cancel",IDCANCEL,204,222,48,12 + DEFPUSHBUTTON "OK",IDOK,144,210,48,12,NOT WS_VISIBLE + PUSHBUTTON "Cancel",IDCANCEL,204,210,48,12 CONTROL "",IDC_LIST_PROGRESS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER,12,12,240,84 - EDITTEXT IDC_EDIT_LOG,12,96,240,120,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL + EDITTEXT IDC_EDIT_LOG,12,96,240,102,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL CONTROL "E&ject the player on completion",IDC_CHECK_SAFEREMOVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,222,120,12 - CONTROL "Don't &close",IDC_CHECK_DONT_CLOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,144,222,48,12 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,210,120,12 + CONTROL "Don't &close",IDC_CHECK_DONT_CLOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,144,210,48,12 END @@ -142,7 +153,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 256 TOPMARGIN, 7 - BOTTOMMARGIN, 239 + BOTTOMMARGIN, 227 END IDD_PROCESSING, DIALOG @@ -150,7 +161,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 256 TOPMARGIN, 7 - BOTTOMMARGIN, 239 + BOTTOMMARGIN, 227 END END #endif // APSTUDIO_INVOKED @@ -316,8 +327,8 @@ // // Generated from the TEXTINCLUDE 3 resource. // -//CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "res\\easypmp_win32gui.exe.manifest" + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED Modified: trunk/pmplib/frontend/easypmp/win32gui/maindlg.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/maindlg.h 2007-02-08 16:41:30 UTC (rev 310) +++ trunk/pmplib/frontend/easypmp/win32gui/maindlg.h 2007-02-08 17:31:14 UTC (rev 311) @@ -70,8 +70,6 @@ BEGIN_DDX_MAP(CMainDlg) DDX_RADIO(IDC_RADIO_DATABASE, m_setting.iDBProces) DDX_RADIO(IDC_RADIO_PLAYLIST, m_setting.iPlaylistProcess) - DDX_CHECK(IDC_CHECK_PL_PLAYLIST, m_setting.bConvertInPlaylist) - DDX_CHECK(IDC_CHECK_PL_MUSIC, m_setting.bConvertInMusic) DDX_CHECK(IDC_CHECK_PL_FIND, m_setting.bSearchMissing) DDX_CHECK(IDC_CHECK_PL_SKIP, m_setting.bSkipMissing) DDX_CHECK(IDC_CHECK_PL_JSPL, m_setting.bJSPL) Modified: trunk/pmplib/frontend/easypmp/win32gui/preference.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/preference.h 2007-02-08 16:41:30 UTC (rev 310) +++ trunk/pmplib/frontend/easypmp/win32gui/preference.h 2007-02-08 17:31:14 UTC (rev 311) @@ -34,8 +34,6 @@ int iMediaInfoSource; CString strStripWords; int iPlaylistProcess; - BOOL bConvertInPlaylist; - BOOL bConvertInMusic; BOOL bSearchMissing; BOOL bSkipMissing; BOOL bJSPL; @@ -53,8 +51,6 @@ iMediaInfoSource = 0; strStripWords = _T("the"); iPlaylistProcess = 2; - bConvertInPlaylist = TRUE; - bConvertInMusic = TRUE; bSearchMissing = TRUE; bSkipMissing = FALSE; bJSPL = FALSE; @@ -105,8 +101,6 @@ persistInt(iMediaInfoSource, _T("Database"), _T("MediaInfoSource"), szSettingFile, storing); persistString(strStripWords, _T("Database"), _T("StripWords"), szSettingFile, storing); persistInt(iPlaylistProcess, _T("Playlist"), _T("Process"), szSettingFile, storing); - persistBool(bConvertInPlaylist, _T("Playlist"), _T("ConvertPlaylist"), szSettingFile, storing); - persistBool(bConvertInMusic, _T("Playlist"), _T("ConvertMusic"), szSettingFile, storing); persistBool(bSearchMissing, _T("Playlist"), _T("SearchMissing"), szSettingFile, storing); persistBool(bSkipMissing, _T("Playlist"), _T("SkipMissing"), szSettingFile, storing); persistBool(bJSPL, _T("Playlist"), _T("JSPL"), szSettingFile, storing); @@ -199,17 +193,18 @@ USES_CONVERSION; if (pmp) { - strPlayerLocation = UCS2CT(pmp->env.path_to_root.path); - strPlayerIdentifier = A2CT(pmp->decl.id); - strPlayerDescription = A2CT(pmp->decl.name); - strPlayerDescription += _T(""); - if (*pmp->decl.version) { + strPlayerLocation = UCS2CT(pmp->info.path_to_root); + strPlayerIdentifier = A2CT(pmp->info.decl.id); + strPlayerDescription = A2CT(pmp->info.decl.manufacturer); + strPlayerDescription += _T(" "); + strPlayerDescription += A2CT(pmp->info.decl.name); + if (*pmp->info.decl.version) { strPlayerDescription += _T(" "); - strPlayerDescription += A2CT(pmp->decl.version); + strPlayerDescription += A2CT(pmp->info.decl.version); } - if (*pmp->decl.mode) { + if (*pmp->info.decl.mode) { strPlayerDescription += _T(" "); - strPlayerDescription += A2CT(pmp->decl.mode); + strPlayerDescription += A2CT(pmp->info.decl.mode); } } else { strPlayerIdentifier = _T(""); Modified: trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-02-08 16:41:30 UTC (rev 310) +++ trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-02-08 17:31:14 UTC (rev 311) @@ -47,13 +47,13 @@ } enum { - PHASE_ENUMERATE_MUSIC = 0, + PHASE_OPEN_DEVICE = 0, + PHASE_ENUMERATE_MUSIC, PHASE_ENUMERATE_PLAYLIST, - PHASE_DATABASE_READ, - PHASE_DATABASE_OBTAIN, - PHASE_DATABASE_UPDATE, - PHASE_DATABASE_WRITE, + PHASE_MUSIC_OBTAIN, + PHASE_MUSIC_UPDATE, PHASE_PLAYLIST_CONVERT, + PHASE_CLOSE_DEVICE, }; enum { @@ -278,8 +278,6 @@ case 1: opt.verb |= MODE_PLAYLIST; break; case 2: opt.verb |= (MODE_PLAYLIST | MODE_PLAYLIST_RECONVERT); break; } - if (m_preference.bConvertInMusic) opt.verb |= MODE_PLAYLIST_MUSIC; - if (m_preference.bConvertInPlaylist) opt.verb |= MODE_PLAYLIST_PLAYLIST; if (m_preference.bSearchMissing) opt.verb |= MODE_PLAYLIST_FIND; if (m_preference.bSkipMissing) opt.verb |= MODE_PLAYLIST_SKIP; if (m_preference.bJSPL) opt.verb |= MODE_PLAYLIST_JSPL; @@ -306,13 +304,13 @@ m_ctrlListProgress.InsertColumn(0, _T("Task"), LVCFMT_LEFT, -1, -1); // Insert tasks. + m_ctrlListProgress.InsertItem(PHASE_OPEN_DEVICE, _T("Opening the device"), IDI_QUEUING); m_ctrlListProgress.InsertItem(PHASE_ENUMERATE_MUSIC, _T("Enumerating music files"), IDI_QUEUING); m_ctrlListProgress.InsertItem(PHASE_ENUMERATE_PLAYLIST, _T("Enumerating playlist files"), IDI_QUEUING); - m_ctrlListProgress.InsertItem(PHASE_DATABASE_READ, _T("Reading the database"), IDI_QUEUING); - m_ctrlListProgress.InsertItem(PHASE_DATABASE_OBTAIN, _T("Obtaining media information"), IDI_QUEUING); - m_ctrlListProgress.InsertItem(PHASE_DATABASE_UPDATE, _T("Updating the database"), IDI_QUEUING); - m_ctrlListProgress.InsertItem(PHASE_DATABASE_WRITE, _T("Writing the database"), IDI_QUEUING); + m_ctrlListProgress.InsertItem(PHASE_MUSIC_OBTAIN, _T("Obtaining media information"), IDI_QUEUING); + m_ctrlListProgress.InsertItem(PHASE_MUSIC_UPDATE, _T("Updating the music database"), IDI_QUEUING); m_ctrlListProgress.InsertItem(PHASE_PLAYLIST_CONVERT, _T("Converting playlists"), IDI_QUEUING); + m_ctrlListProgress.InsertItem(PHASE_CLOSE_DEVICE, _T("Closing the device"), IDI_QUEUING); // Expand the size of the task column. m_ctrlListProgress.SetColumnWidth(0, LVSCW_AUTOSIZE); @@ -331,12 +329,35 @@ return 1; } + // Generate open flag. + int openflag = 0; + if (opt.verb & MODE_DATABASE) { + openflag |= PMPOF_MUSIC_DB_WRITE; + if (opt.verb & MODE_DATABASE_UPDATE) { + openflag |= PMPOF_MUSIC_DB_READ; + } + } + if (opt.verb & MODE_DATABASE_REPR) { + openflag |= PMPOF_MUSIC_DB_READ; + } + if (opt.verb & MODE_PLAYLIST) { + openflag |= PMPOF_MUSIC_PL_WRITE; + } + // Show copyright information. showCopyrightInformation(); // Show player information. showPlayerInformation(pmp); + // + this->setState(PHASE_OPEN_DEVICE, STATE_PROCESSING); + result = pmp->open(pmp, openflag); + if (result != 0) { + goto error_exit; + } + this->setState(PHASE_OPEN_DEVICE, STATE_DONE); + // Enumerate target files. easypmp_filelist_t musics, playlists; @@ -374,20 +395,17 @@ write_log(LL_TRACE, _T("")); } - // Execute jobs. - if (opt.verb & MODE_DATABASE) { - result = easypmp_database(&musics, pmp, &opt, &records, &num_records, easypmp_progress, this); + // Update database entries for database mode and JSPL playlists. + if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST_JSPL)) { + result = easypmp_database(pmp, &musics, &opt, &records, &num_records, easypmp_progress, this); if (result != 0) { goto error_exit; } } + + // Convert playlists. if (opt.verb & MODE_PLAYLIST) { - if ((opt.verb & MODE_PLAYLIST_JSPL) && (!records)) { - setState(PHASE_DATABASE_READ, STATE_PROCESSING); - easypmp_database_read(pmp, &opt, &records, &num_records, easypmp_progress, this); - setState(PHASE_DATABASE_READ, STATE_DONE); - } - result = easypmp_playlist(&playlists, &musics, pmp, &opt, records, num_records, easypmp_progress, this); + result = easypmp_playlist(pmp, &playlists, &musics, &opt, records, num_records, easypmp_progress, this); if (result != 0) { goto error_exit; } @@ -399,12 +417,12 @@ /* Eject the device. */ m_preference.bSafelyRemove = IsDlgButtonChecked(IDC_CHECK_SAFEREMOVE) == BST_CHECKED ? TRUE : FALSE; if (m_preference.bSafelyRemove) { - if (ucs2len(pmp->env.path_to_root.path) > 2 && pmp->env.path_to_root.path[1] == ':') { + if (ucs2len(pmp->info.path_to_root) > 2 && pmp->info.path_to_root[1] == ':') { int i; const int max_tries = 20; CHAR szDrive[3] = {0, 0, 0}; - szDrive[0] = (CHAR)pmp->env.path_to_root.path[0]; - szDrive[1] = (CHAR)pmp->env.path_to_root.path[1]; + szDrive[0] = (CHAR)pmp->info.path_to_root[0]; + szDrive[1] = (CHAR)pmp->info.path_to_root[1]; szDrive[2] = 0; ejectdevice_t* ed = ejectdevice_init(); @@ -434,27 +452,28 @@ } } - if (records) { - /* Free the record array. */ - int i; - for (i = 0;i < num_records;++i) { - pmplib_record_finish(&records[i]); - } - free(records); + // Close the device. + this->setState(PHASE_CLOSE_DEVICE, STATE_PROCESSING); + result = pmp->close(pmp); + if (result != 0) { + goto error_exit; } + this->setState(PHASE_CLOSE_DEVICE, STATE_DONE); + + // Free the music records. + if (records && num_records) { + pmplib_records_finish(records, num_records); + } + easypmp_free_filelist(&playlists); easypmp_free_filelist(&musics); pmp->release(pmp); return 0; error_exit: - if (records) { - /* Free the record array. */ - int i; - for (i = 0;i < num_records;++i) { - pmplib_record_finish(&records[i]); - } - free(records); + // Free the music records. + if (records && num_records) { + pmplib_records_finish(records, num_records); } easypmp_free_filelist(&playlists); easypmp_free_filelist(&musics); @@ -515,9 +534,7 @@ CProcessingDlg* dlg = (CProcessingDlg*)instance; switch (phase) { - case EASYPMPDBP_START: - break; - case EASYPMPDBP_READ|EASYPMPSP_START: +/* case EASYPMPDBP_READ|EASYPMPSP_START: dlg->setState(PHASE_DATABASE_READ, STATE_PROCESSING); dlg->write_log(LL_TRACE, _T("[Reading database]")); break; @@ -536,39 +553,39 @@ dlg->setState(PHASE_DATABASE_READ, STATE_DONE); dlg->write_log(LL_TRACE, str); dlg->write_log(LL_TRACE, _T("")); - break; - case EASYPMPDBP_GMI|EASYPMPSP_START: - dlg->setState(PHASE_DATABASE_OBTAIN, STATE_PROCESSING); - dlg->m_ctrlListProgress.GetSubItemRect(PHASE_DATABASE_OBTAIN, 1, LVIR_BOUNDS, &rt); + break;*/ + case EASYPMPP_MUSIC_GMI|EASYPMPSP_START: + dlg->setState(PHASE_MUSIC_OBTAIN, STATE_PROCESSING); + dlg->m_ctrlListProgress.GetSubItemRect(PHASE_MUSIC_OBTAIN, 1, LVIR_BOUNDS, &rt); dlg->m_ctrlProgress.SetWindowPos(HWND_TOP, rt, SWP_SHOWWINDOW); //dlg->m_ctrlProgress.Create(dlg->m_ctrlListProgress, rt, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); dlg->m_ctrlProgress.SetRange(0, param_int); dlg->write_log(LL_TRACE, _T("[Obtaining media information]")); break; - case EASYPMPDBP_GMI|EASYPMPSP_PROGRESS: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_PROGRESS: str.Format(_T("(%d) %s"), param_int+1, UCS2CT(filepath_skippath(param_str))); dlg->m_ctrlProgress.SetText(str); dlg->m_ctrlProgress.SetPos(param_int); dlg->write_log(LL_TRACE, _T("%s"), UCS2CT(param_str)); break; - case EASYPMPDBP_GMI|EASYPMPSP_END: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: dlg->m_ctrlProgress.ShowWindow(SW_HIDE); //dlg->m_ctrlProgress.DestroyWindow(); str.Format(_T("%d files were imported"), param_int); - dlg->setProgress(PHASE_DATABASE_OBTAIN, str); - dlg->setState(PHASE_DATABASE_OBTAIN, STATE_DONE); + dlg->setProgress(PHASE_MUSIC_OBTAIN, str); + dlg->setState(PHASE_MUSIC_OBTAIN, STATE_DONE); dlg->write_log(LL_TRACE, _T("")); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_START: - dlg->setState(PHASE_DATABASE_UPDATE, STATE_PROCESSING); + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_START: + dlg->setState(PHASE_MUSIC_UPDATE, STATE_PROCESSING); dlg->write_log(LL_TRACE, _T("[Updating database]")); break; - case EASYPMPDBP_UPDATE|EASYPMPSP_END: - dlg->setState(PHASE_DATABASE_UPDATE, STATE_DONE); - dlg->setProgress(PHASE_DATABASE_UPDATE, _T("Done")); + case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_END: + dlg->setState(PHASE_MUSIC_UPDATE, STATE_DONE); + dlg->setProgress(PHASE_MUSIC_UPDATE, _T("Done")); dlg->write_log(LL_TRACE, _T("")); break; - case EASYPMPDBP_WRITE|EASYPMPSP_START: +/* case EASYPMPDBP_WRITE|EASYPMPSP_START: dlg->setState(PHASE_DATABASE_WRITE, STATE_PROCESSING); dlg->write_log(LL_TRACE, _T("[Writing database]")); break; @@ -578,13 +595,9 @@ dlg->setState(PHASE_DATABASE_WRITE, STATE_DONE); dlg->setProgress(PHASE_DATABASE_WRITE, _T("Done")); dlg->write_log(LL_TRACE, _T("")); - break; - case EASYPMPDBP_END: - break; + break;*/ - case EASYPMPPLP_START: - break; - case EASYPMPPLP_CONVERT|EASYPMPSP_START: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_START: dlg->setState(PHASE_PLAYLIST_CONVERT, STATE_PROCESSING); dlg->m_ctrlListProgress.GetSubItemRect(PHASE_PLAYLIST_CONVERT, 1, LVIR_BOUNDS, &rt); dlg->m_ctrlProgress.SetWindowPos(HWND_TOP, rt, SWP_SHOWWINDOW); @@ -592,30 +605,30 @@ dlg->m_ctrlProgress.SetRange(0, param_int); dlg->write_log(LL_TRACE, _T("[Playlist conversion]")); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_PROGRESS: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_PROGRESS: str.Format(_T("(%d) %s"), param_int+1, UCS2CT(filepath_skippath(param_str))); dlg->m_ctrlProgress.SetText(str); dlg->m_ctrlProgress.SetPos(param_int); dlg->write_log(LL_TRACE, _T("%s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_WARN_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_WARN_PLAYLIST: dlg->m_bFailed = TRUE; dlg->write_log(LL_WARNING, _T("WARNING: %s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_SKIP_PLAYLIST: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_SKIP_PLAYLIST: dlg->m_bFailed = TRUE; dlg->write_log(LL_ERROR, _T("ERROR: %s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_MISSING_MEDIA: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_MISSING_MEDIA: dlg->write_log(LL_INFO, _T(" %s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_ERROR: dlg->write_log(LL_ERROR, _T("JSPL(ERROR): %s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_OUTPUT: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_JSPL_OUTPUT: dlg->write_log(LL_INFO, _T("JSPL: %s"), UCS2CT(param_str)); break; - case EASYPMPPLP_CONVERT|EASYPMPSP_END: + case EASYPMPP_PLAYLIST_CONVERT|EASYPMPSP_END: dlg->m_ctrlProgress.ShowWindow(SW_HIDE); //dlg->m_ctrlProgress.DestroyWindow(); str.Format(_T("%d playlists were succeeded"), param_int); @@ -623,8 +636,6 @@ dlg->setState(PHASE_PLAYLIST_CONVERT, STATE_DONE); dlg->write_log(LL_TRACE, _T("")); break; - case EASYPMPPLP_END: - break; } return (dlg->m_bCancel) ? -1 : 0; @@ -670,15 +681,15 @@ USES_CONVERSION; write_log(LL_INFO, _T("[Player information]")); - write_log(LL_INFO, _T("Device identifier: %s"), A2CT(pmp->decl.id)); - write_log(LL_INFO, _T("Product name: %s"), A2CT(pmp->decl.name)); - write_log(LL_TRACE, _T("Firmware mode: %s"), A2CT(pmp->decl.mode)); - write_log(LL_INFO, _T("Firmware version: %s"), A2CT(pmp->decl.version)); - write_log(LL_TRACE, _T("Default language: %s"), A2CT(pmp->decl.language)); - write_log(LL_TRACE, _T("Root directory: %s"), UCS2CT(pmp->env.path_to_root.path)); - write_log(LL_TRACE, _T("Music directory: %s"), UCS2CT(pmp->env.path_to_music.path)); - write_log(LL_TRACE, _T("Playlist directory: %s"), UCS2CT(pmp->env.path_to_playlist.path)); - write_log(LL_TRACE, _T("Playlist extension: %s"), UCS2CT(pmp->env.playlist_ext)); + write_log(LL_INFO, _T("Device identifier: %s"), A2CT(pmp->info.decl.id)); + write_log(LL_INFO, _T("Product manufacturer: %s"), A2CT(pmp->info.decl.manufacturer)); + write_log(LL_INFO, _T("Product name: %s"), A2CT(pmp->info.decl.name)); + write_log(LL_INFO, _T("Firmware mode: %s"), A2CT(pmp->info.decl.mode)); + write_log(LL_INFO, _T("Firmware version: %s"), A2CT(pmp->info.decl.version)); + write_log(LL_INFO, _T("Default language: %s"), A2CT(pmp->info.decl.language)); + write_log(LL_INFO, _T("Root directory: %s"), UCS2CT(pmp->info.path_to_root)); + write_log(LL_INFO, _T("Music directory: %s"), UCS2CT(pmp->info.path_to_music)); + write_log(LL_INFO, _T("Playlist directory: %s"), UCS2CT(pmp->info.path_to_playlist)); write_log(LL_INFO, _T("")); } Modified: trunk/pmplib/pmp.sln =================================================================== --- trunk/pmplib/pmp.sln 2007-02-08 16:41:30 UTC (rev 310) +++ trunk/pmplib/pmp.sln 2007-02-08 17:31:14 UTC (rev 311) @@ -42,11 +42,13 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "easypmp_win32gui", "frontend\easypmp\win32gui\easypmp_win32gui.vcproj", "{45CCFC7B-42B4-4FF9-AF43-FC3626B1672F}" ProjectSection(ProjectDependencies) = postProject + {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} + {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} + {544769C2-6989-452F-B626-E442CAC6553B} = {544769C2-6989-452F-B626-E442CAC6553B} + {C74FE9C9-B5C4-438A-B157-9BCB6C8A7546} = {C74FE9C9-B5C4-438A-B157-9BCB6C8A7546} {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} = {8BFE7DD6-F825-42BA-A7D7-EFCDCC9D686A} {3575EFC2-9051-467A-BEB4-E71E2F8664D7} = {3575EFC2-9051-467A-BEB4-E71E2F8664D7} {3419FA86-F518-4D3B-94C6-B05436439102} = {3419FA86-F518-4D3B-94C6-B05436439102} - {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} = {2548F270-FFCF-43B4-BB9D-D5AAD5B5FEF1} - {E393575C-6B10-43BD-B2C0-63C5040A49F7} = {E393575C-6B10-43BD-B2C0-63C5040A49F7} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pmp_portalplayer1", "lib\pmp_portalplayer1\pmp_portalplayer1.vcproj", "{544769C2-6989-452F-B626-E442CAC6553B}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-09 02:52:19
|
Revision: 317 http://svn.sourceforge.net/pmplib/?rev=317&view=rev Author: nyaochi Date: 2007-02-08 18:52:20 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Fix build on POSIX environments. Modified Paths: -------------- trunk/pmplib/Makefile.am trunk/pmplib/configure.in trunk/pmplib/frontend/easypmp/cui/console_posix.c trunk/pmplib/lib/filepath/Makefile.am trunk/pmplib/lib/filepath/filepath_posix.c trunk/pmplib/lib/filepath/rel2abs.c trunk/pmplib/lib/filepath/rel2abs.h trunk/pmplib/lib/pmp/Makefile.am trunk/pmplib/lib/pmp/pmp_posix.c trunk/pmplib/lib/ucs2/Makefile.am trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/Makefile.am =================================================================== --- trunk/pmplib/Makefile.am 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/Makefile.am 2007-02-09 02:52:20 UTC (rev 317) @@ -1,6 +1,6 @@ # $Id$ -SUBDIRS = m4 libltdl lib/ucs2 lib/filepath lib/pmp lib/gmi lib/playlist lib/pmp_irivnavi lib/pmp_portalplayer1 lib/pmp_iriverplus2 lib/pmp_iriverplus3 frontend/easypmp/cui +SUBDIRS = m4 libltdl include lib/ucs2 lib/filepath lib/pmp lib/gmi lib/playlist lib/pmp_irivnavi lib/pmp_portalplayer1 lib/pmp_iriverplus2 lib/pmp_iriverplus3 frontend/easypmp/cui docdir = $(prefix)/share/doc/@PACKAGE@ doc_DATA = README INSTALL COPYING AUTHORS ChangeLog Modified: trunk/pmplib/configure.in =================================================================== --- trunk/pmplib/configure.in 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/configure.in 2007-02-09 02:52:20 UTC (rev 317) @@ -228,7 +228,7 @@ dnl ------------------------------------------------------------------ dnl Output the configure results. dnl ------------------------------------------------------------------ -AC_CONFIG_FILES(Makefile m4/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/pmp/Makefile lib/gmi/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile) +AC_CONFIG_FILES(Makefile m4/Makefile include/Makefile include/pmplib/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/pmp/Makefile lib/gmi/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile) if test -n "$JS_CFLAGS" ; then AC_DEFINE([HAVE_JSAPI_H], 1, [Define if you have the jsapi.h header]) Modified: trunk/pmplib/frontend/easypmp/cui/console_posix.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/console_posix.c 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/frontend/easypmp/cui/console_posix.c 2007-02-09 02:52:20 UTC (rev 317) @@ -38,7 +38,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> -#include <ucs2char.h> +#include <pmplib/ucs2char.h> #ifdef HAVE_STRING_H #include <string.h> Modified: trunk/pmplib/lib/filepath/Makefile.am =================================================================== --- trunk/pmplib/lib/filepath/Makefile.am 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/filepath/Makefile.am 2007-02-09 02:52:20 UTC (rev 317) @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libfilepath.la libfilepath_la_SOURCES = \ - ../../include/filepath.h \ + ../../include/pmplib/filepath.h \ filepath_posix.c \ rel2abs.h \ rel2abs.c Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-09 02:52:20 UTC (rev 317) @@ -34,7 +34,7 @@ #include <string.h> #include <sys/stat.h> -#include "filepath.h" +#include <pmplib/filepath.h> #include "rel2abs.h" int find_file(const ucs2char_t* path, int recursive, filepath_findfile_callback callback, void *instance) @@ -265,14 +265,14 @@ return (*path != PATHCHAR); } -int filepath_file_exists(const ucs2char_t *path) +int filepath_file_exists(const ucs2char_t *filename) { int ret = 0; struct stat st; char *mbs_path = ucs2dupmbs(filename); if (mbs_path) { - path_decode(mbs_path); + filepath_decode(mbs_path); //fprintf(stderr, "is_exist: %s\n", mbs_path); ret = open(mbs_path, 0); free(mbs_path); @@ -364,3 +364,54 @@ } return 0; } + +time_t filepath_mtime(const ucs2char_t *filename) +{ + int ret = 0; + struct stat st; + char *mbs_path = ucs2dupmbs(filename); + + if (mbs_path) { + filepath_decode(mbs_path); + ret = stat(mbs_path, &st); + free(mbs_path); + if (ret == 0) { + return st.st_mtime; + } + } + return 0; +} + +uint32_t filepath_size(const ucs2char_t *filename) +{ + int ret = 0; + struct stat st; + char *mbs_path = ucs2dupmbs(filename); + + if (mbs_path) { + filepath_decode(mbs_path); + ret = stat(mbs_path, &st); + free(mbs_path); + if (ret == 0) { + return (uint32_t)st.st_size; + } + } + return 0; +} + +int filepath_is_dir(const ucs2char_t *filename) +{ + int ret = 0; + struct stat st; + char *mbs_path = ucs2dupmbs(filename); + + if (mbs_path) { + filepath_decode(mbs_path); + ret = stat(mbs_path, &st); + free(mbs_path); + if (ret == 0) { + return ((st.st_mode & S_IFMT) == S_IFDIR); + } + } + return 0; +} Modified: trunk/pmplib/lib/filepath/rel2abs.c =================================================================== --- trunk/pmplib/lib/filepath/rel2abs.c 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/filepath/rel2abs.c 2007-02-09 02:52:20 UTC (rev 317) @@ -39,7 +39,7 @@ #include <os.h> #include <errno.h> #include <stdlib.h> -#include <ucs2char.h> +#include <pmplib/ucs2char.h> #include "rel2abs.h" Modified: trunk/pmplib/lib/filepath/rel2abs.h =================================================================== --- trunk/pmplib/lib/filepath/rel2abs.h 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/filepath/rel2abs.h 2007-02-09 02:52:20 UTC (rev 317) @@ -25,7 +25,7 @@ #ifndef __REL2ABS_H__ #define __REL2ABS_H__ -#include <ucs2char.h> +#include <pmplib/ucs2char.h> /** * \addtogroup filepath Modified: trunk/pmplib/lib/pmp/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp/Makefile.am 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/pmp/Makefile.am 2007-02-09 02:52:20 UTC (rev 317) @@ -3,7 +3,8 @@ lib_LTLIBRARIES = libpmp.la libpmp_la_SOURCES = \ - ../../include/pmp.h \ + ../../include/pmplib/pmp.h \ + ../../include/pmplib/os_types.h \ pmp.c \ pmp_posix.c Modified: trunk/pmplib/lib/pmp/pmp_posix.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/pmp/pmp_posix.c 2007-02-09 02:52:20 UTC (rev 317) @@ -32,11 +32,10 @@ #include <ltdl.h> #include <os.h> -#include <ucs2char.h> +#include <pmplib/ucs2char.h> +#include <pmplib/filepath.h> +#include <pmplib/pmp.h> -#include <filepath.h> -#include <pmp.h> - struct tag_pmplib_t { uint32_t num_plugins; lt_dlhandle *plugins; Modified: trunk/pmplib/lib/ucs2/Makefile.am =================================================================== --- trunk/pmplib/lib/ucs2/Makefile.am 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/ucs2/Makefile.am 2007-02-09 02:52:20 UTC (rev 317) @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libucs2.la libucs2_la_SOURCES = \ - ../../include/ucs2char.h \ + ../../include/pmplib/ucs2char.h \ ucs2char.c \ ucs2char_iconv.c Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-09 02:29:45 UTC (rev 316) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-09 02:52:20 UTC (rev 317) @@ -231,7 +231,7 @@ -static void path_decode(char *p) +static void filepath_decode(char *p) { while (*p) { if (*p == 0x005C) { @@ -248,7 +248,7 @@ char* mbs = (char *)alloca(mbs_size * sizeof(char)); if (mbs) { ucs2tombs(mbs, mbs_size, ucs2str, ucs2len(ucs2str)+1); - return (fputs(mbs, fp) != EOF : 0 ? 1); + return (fputs(mbs, fp) != EOF ? 0 : 1); } else { return 1; } @@ -261,61 +261,10 @@ if (mbs_filename) { /* Convert '\\' to '/'. */ - path_decode(mbs_filename); + filepath_decode(mbs_filename); //fprintf(stderr, "fopen: %s\n", mbs_filename); fp = fopen(mbs_filename, mode); } free(mbs_filename); return fp; } - -time_t filepath_mtime(const ucs2char_t *filename) -{ - int ret = 0; - struct stat st; - char *mbs_path = ucs2dupmbs(filename); - - if (mbs_path) { - path_decode(mbs_path); - ret = stat(mbs_path, &st); - free(mbs_path); - if (ret == 0) { - return st.st_mtime; - } - } - return 0; -} - -uint32_t filepath_size(const ucs2char_t *filename) -{ - int ret = 0; - struct stat st; - char *mbs_path = ucs2dupmbs(filename); - - if (mbs_path) { - path_decode(mbs_path); - ret = stat(mbs_path, &st); - free(mbs_path); - if (ret == 0) { - return (uint32_t)st.st_size; - } - } - return 0; -} - -int filepath_is_dir(const ucs2char_t *filename) -{ - int ret = 0; - struct stat st; - char *mbs_path = ucs2dupmbs(filename); - - if (mbs_path) { - path_decode(mbs_path); - ret = stat(mbs_path, &st); - free(mbs_path); - if (ret == 0) { - return ((st.st_mode & S_IFMT) == S_IFDIR); - } - } - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-09 05:11:58
|
Revision: 319 http://svn.sourceforge.net/pmplib/?rev=319&view=rev Author: nyaochi Date: 2007-02-08 21:11:59 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Initial attempt to build pmplib-*.rpm Modified Paths: -------------- trunk/pmplib/configure.in trunk/pmplib/include/Makefile.am trunk/pmplib/lib/pmp_iriverplus2/Makefile.am trunk/pmplib/lib/pmp_iriverplus3/Makefile.am trunk/pmplib/lib/pmp_irivnavi/Makefile.am trunk/pmplib/lib/pmp_portalplayer1/Makefile.am Added Paths: ----------- trunk/pmplib/pmplib.spec.in Modified: trunk/pmplib/configure.in =================================================================== --- trunk/pmplib/configure.in 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/configure.in 2007-02-09 05:11:59 UTC (rev 319) @@ -228,7 +228,7 @@ dnl ------------------------------------------------------------------ dnl Output the configure results. dnl ------------------------------------------------------------------ -AC_CONFIG_FILES(Makefile m4/Makefile include/Makefile include/pmplib/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/pmp/Makefile lib/gmi/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile) +AC_CONFIG_FILES(Makefile m4/Makefile include/Makefile include/pmplib/Makefile lib/ucs2/Makefile lib/filepath/Makefile lib/pmp/Makefile lib/gmi/Makefile lib/pmp_irivnavi/Makefile lib/pmp_portalplayer1/Makefile lib/pmp_iriverplus2/Makefile lib/pmp_iriverplus3/Makefile lib/playlist/Makefile frontend/easypmp/cui/Makefile pmplib.spec) if test -n "$JS_CFLAGS" ; then AC_DEFINE([HAVE_JSAPI_H], 1, [Define if you have the jsapi.h header]) Modified: trunk/pmplib/include/Makefile.am =================================================================== --- trunk/pmplib/include/Makefile.am 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/include/Makefile.am 2007-02-09 05:11:59 UTC (rev 319) @@ -1,3 +1,9 @@ # $Id:$ SUBDIRS = pmplib + +EXTRA_DIST = \ + os.h \ + gmi.h \ + playlist.h \ + ucs2string.h Modified: trunk/pmplib/lib/pmp_iriverplus2/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/Makefile.am 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/lib/pmp_iriverplus2/Makefile.am 2007-02-09 05:11:59 UTC (rev 319) @@ -4,7 +4,6 @@ pmp_LTLIBRARIES = iriverplus2.la iriverplus2_la_SOURCES = \ - ../../include/pmp.h \ dat.c \ idx.c \ idx_header.c \ Modified: trunk/pmplib/lib/pmp_iriverplus3/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/Makefile.am 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/lib/pmp_iriverplus3/Makefile.am 2007-02-09 05:11:59 UTC (rev 319) @@ -4,7 +4,6 @@ pmp_LTLIBRARIES = iriverplus3.la iriverplus3_la_SOURCES = \ - ../../include/pmp.h \ dat.h \ dat.c \ dic.h \ Modified: trunk/pmplib/lib/pmp_irivnavi/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/Makefile.am 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/lib/pmp_irivnavi/Makefile.am 2007-02-09 05:11:59 UTC (rev 319) @@ -4,8 +4,6 @@ pmp_LTLIBRARIES = irivnavi.la irivnavi_la_SOURCES = \ - ../../include/pmp.h \ - ../../include/pmphelp.h \ irivnavi.c \ irivnavi.h \ playlist.c \ Modified: trunk/pmplib/lib/pmp_portalplayer1/Makefile.am =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-02-09 04:54:37 UTC (rev 318) +++ trunk/pmplib/lib/pmp_portalplayer1/Makefile.am 2007-02-09 05:11:59 UTC (rev 319) @@ -4,7 +4,6 @@ pmp_LTLIBRARIES = portalplayer1.la portalplayer1_la_SOURCES = \ - ../../include/pmp.h \ hdr.c \ hdr_template.c \ hdr_template.h \ Added: trunk/pmplib/pmplib.spec.in =================================================================== --- trunk/pmplib/pmplib.spec.in (rev 0) +++ trunk/pmplib/pmplib.spec.in 2007-02-09 05:11:59 UTC (rev 319) @@ -0,0 +1,92 @@ +%define name @PACKAGE@ +%define version @VERSION@ +%define release 1 +%define prefix %{_usr} +%define docdir %{_defaultdocdir} + +# Preamble +Summary: Portable Media Player library (PMPlib) +Name: %{name} +Version: %{version} +Release: %{release} +License: LGPL +Vendor: The PMPlib Project +Packager: Naoaki Okazaki <ny...@us...> +URL: http://pmplib.sourceforge.net/ +Group: Applications/Multimedia +Source: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-root +BuildRequires: gcc => 3.0.1, libid3tag-devel, zlib-devel, libogg-devel, libvorbis-devel + +%description +Portable Media Player library (PMPlib) is a management software/library for various portable media players. + +%package devel +Summary: Shared and static libraries for PMPlib +Group: Development/Libraries +Requires: %{name} = %{version} + +%description devel +Portable Media Player library (PMPlib) is a management software/library for various portable media players. +This package contains both the shared and the static libraries from the PMPlib project. + +%package tools +Summary: Command-line tools for PMPlib (EasyPMP) +License: GPL +Group: Applications/Multimedia +Requires: %{name} = %{version}, libid3tag, zlib, libogg, libvorbis + +%description tools +Portable Media Player library (PMPlib) is a management software/library for various portable media players. +This package contains a frontend program (EasyPMP) for PMPlib. + +%prep + +%setup + +%build +%configure +%{__make} + +%install +%{__rm} -rf %{buildroot} +%makeinstall + +%post + +%postun + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-,root,root) +%doc AUTHORS COPYING ChangeLog INSTALL NEWS README +%{_libdir}/pmplib/irivnavi.so +%{_libdir}/pmplib/portalplayer1.so +%{_libdir}/pmplib/iriverplus2.so +%{_libdir}/pmplib/iriverplus3.so +%{_libdir}/libpmp.so* + +%files devel +%defattr(-,root,root) +%{_libdir}/pmplib/irivnavi.a +%{_libdir}/pmplib/irivnavi.la +%{_libdir}/pmplib/portalplayer1.a +%{_libdir}/pmplib/portalplayer1.la +%{_libdir}/pmplib/iriverplus2.a +%{_libdir}/pmplib/iriverplus2.la +%{_libdir}/pmplib/iriverplus3.a +%{_libdir}/pmplib/iriverplus3.la +%{_libdir}/libpmp.a +%{_libdir}/libpmp.la +%{_includedir}/* + +%files tools +%defattr(-,root,root) +%{_bindir}/easypmp +%{_mandir}/man1/easypmp.1* + +%changelog +* Fri Feb 9 2007 Naoaki Okazaki <ny...@us...> 0.14 +- Initial build This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-09 17:19:10
|
Revision: 320 http://svn.sourceforge.net/pmplib/?rev=320&view=rev Author: nyaochi Date: 2007-02-09 08:13:11 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Documentation of pmp.h Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/include/pmplib/pmp.h trunk/pmplib/lib/filepath/filepath.vcproj trunk/pmplib/lib/pmp/pmp.vcproj trunk/pmplib/lib/pmp/pmp_win32.c trunk/pmplib/lib/pmp_iriverplus2/idx.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/pmplib/lib/pmp_portalplayer1/pp1db.c trunk/pmplib/lib/ucs2/ucs2.vcproj Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-09 16:13:11 UTC (rev 320) @@ -40,13 +40,6 @@ * @{ */ -static void device_show_pathflag(int flag, FILE* fp) -{ - if (flag & PMPPEF_RECURSIVE) { - fprintf(fp, " sub_directory=yes"); - } -} - // Display a path name using the given string format. void device_show_path(FILE *fp, const char* const format, const ucs2char_t* const path) { Modified: trunk/pmplib/include/pmplib/pmp.h =================================================================== --- trunk/pmplib/include/pmplib/pmp.h 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/include/pmplib/pmp.h 2007-02-09 16:13:11 UTC (rev 320) @@ -24,6 +24,8 @@ #ifndef __PMP_H__ #define __PMP_H__ +#include <pmplib/os_types.h> + #ifdef PMP_EXPORTS #define PMPAPI __declspec(dllexport) #else @@ -55,24 +57,31 @@ struct tag_pmp_music_t; typedef struct tag_pmp_music_t pmp_music_t; /** - * Error codes. + * Status codes. */ enum { + /** Success. */ PMP_SUCCESS = 0, - PMP_DEVICENOTFOUND, - PMP_NOTSUPPORTED, - PMP_INSUFFICIENTMEMORY, - PMP_NOTIMPLIMENTED, - PMPDBE_OUTOFMEMORY, - PMPDBE_NOTFOUND, - PMPDBE_INVALIDTYPE, - PMPDBE_DBINCONSIST, - PMPDBE_NOTINITIALIZED, - PMPDBE_INVALIDLEAFID, - PMPDBE_OPENFORREAD, - PMPDBE_OPENFORWRITE, - PMPDBE_INSUFFICIENT, - PMPPLE_WRITE, + /** Undetermined error. */ + PMPERR_ERROR = 0x80000000, + /** Device is not found or unsupported. */ + PMPERR_DEVICENOTFOUND, + /** Insufficient memory. */ + PMPERR_INSUFFICIENTMEMORY, + /** Operation is not implemented. */ + PMPERR_NOTIMPLIMENTED, + /** The entry is not found. */ + PMPERR_ENTRYNOTFOUND, + /** Inconsistent operation/data. */ + PMPERR_INCONSISTENCY, + /** Error while opening a file for reading. */ + PMPERR_OPENFORREAD, + /** Error while opening a file for writing. */ + PMPERR_OPENFORWRITE, + /** Error while reading a file. */ + PMPERR_READ, + /** Error while writing a file. */ + PMPERR_WRITE, }; /** @@ -108,33 +117,34 @@ #define PMPFOURCC(a, b, c, d) \ ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (uint32_t)(d)) -#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') /**< Unknown codec. */ -#define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') /**< MPEG Audio Layer III */ -#define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') /**< Windows Media Audio */ -#define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') /**< Ogg Vorbis */ -#define PMPCODEC_WAV PMPFOURCC('W','A','V','E') /**< Microsoft Riff WAVE */ +/** Unknown codec. */ +#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ') +/** MPEG Audio Layer III. */ +#define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','1','3') +/** Windows Media Audio. */ +#define PMPCODEC_WMA PMPFOURCC('W','M','A',' ') +/** Ogg Vorbis. */ +#define PMPCODEC_VORBIS PMPFOURCC('O','V','1',' ') +/** Microsoft Riff WAVE. */ +#define PMPCODEC_WAV PMPFOURCC('W','A','V','E') +/** + * Flags for device functionality. + */ enum { - PMPPEF_NONE = 0x0000, - PMPPEF_SUPPORT = 0x0001, - PMPPEF_CONSTANT = 0x0002, - PMPPEF_RECURSIVE = 0x0004, -}; - -enum { - PMPMF_NONE = 0x0000, + /** None. */ + PMPF_NONE = 0x0000, + /** The device supports music database. */ PMPMF_SUPPORT = 0x0001, + /** The device supports subdirs under music directory. */ PMPMF_RECURSIVE = 0x0002, + /** The device supports music playlist. */ + PMPPF_SUPPORT = 0x0010, + /** The device supports subdirs under playlist directory. */ + PMPPF_RECURSIVE = 0x0020, }; -enum { - PMPPF_NONE = 0x0000, - PMPPF_SUPPORT = 0x0001, - PMPPF_RECURSIVE = 0x0002, -}; - - /** * @defgroup device PMPlib Device API * @{ @@ -410,9 +420,23 @@ }; typedef struct tag_pmp_music_record_t pmp_music_record_t; +/** + * Structure for a playlist. + */ typedef struct { + /** + * Name of the playlist. + */ ucs2char_t *name; + + /** + * The number of entries in the playlist. + */ int num_entries; + + /** + * Pointer to an array of entries referring to media files. + */ ucs2char_t **entries; } pmp_playlist_t; @@ -615,30 +639,155 @@ */ PMPAPI result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records); +/** + * Initialize pmp_playlist_t structure. + * + * @param playlist The pointer to pmp_playlist_t instance. + */ PMPAPI void pmplib_playlist_init(pmp_playlist_t* playlist); + +/** + * Uninitialize pmp_playlist_t structure. + * + * This function frees the memory blocks used by the \a playlist. + * + * @param playlist The pointer to pmp_playlist_t instance. + */ PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist); + +/** + * Clone a playlist. + * + * This function copies the values in the \a src playlist to \a dst. + * + * @param dst The pointer to the destination. + * @param src The pointer to the source. + */ PMPAPI void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src); -PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlist, int num_playlists); +/** + * Uninitialize an array of pmp_playlist_t playlists. + * + * This function frees the memory blocks used by each playlist in the array and + * the array itself. + * + * @param playlists The pointer to pmp_playlist_t array. + * @param num_playlists The number of elements in the array. + */ +PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlists, int num_playlists); + +/** + * Clone a pmp_playlist_t array. + * + * This function copies all playlists in the \a src array to \a dst. + * + * @param dst The destination array. + * @param src The source array. + * @param num_records The number of elements in the source array. + */ PMPAPI void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists); /** * @} */ +/** + * \addtogroup pmp_export Export functions of a driver module + * @{ + */ -typedef result_t (*pmplib_create_t)(pmp_t** pmp, const ucs2char_t* path_to_device, const char *devid); +/** + * Prototype of a callback function receiving device IDs from pmplib_create(). + * + * @param instance The user-defined instance value. + * @param devid The device identifier. + */ +typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid); /** - * Prototype for the callback function for receiving device identifiers. + * Query a driver and construct a ::pmp_t instance. + * + * This function queries the driver suitable for the portable media device + * specified by the mount location and/or identifier. A driver module must + * return the interface to the driver (::pmp_t instance) if it supports + * the device. Parameter \a path_to_device is expected to be specified. If + * parameter \a id is not \c NULL, the driver module should return the + * interface to the driver with the device identifier specified in \a id + * parameter. If the parameter \a id is \c NULL, the driver module should + * recognize the model of the device based on the content of the files located + * under \a path_to_device. + * + * @param path_to_device A UCS-2 string representing the location of the + * target device. This parameter cannot be \c NULL. + * @param id A C-string representing the device identifier of + * the target device. If this argument is \c NULL, + * this function tries to recognize the model of the + * device based on the location (\a path_to_device). + * @retval ptr_pmp The pointer to the buffer to receive the pointer + * to the driver interface (::pmp_t instance). + * @retval result_t The status code. + * + * @assert + * @code ptr_pmp != NULL @endcode + * @code path_to_device != NULL @endcode + */ +typedef result_t (*pmplib_create_t)(pmp_t** ptr_pmp, const ucs2char_t* path_to_device, const char *id); + +/** + * Enumerate device identifiers supported by the driver module. * + * The driver module should enumerate the device identifiers supported + * by the module and invoke the \a callback function for each identifier. + * + * @param callback The pointer to the callback function to receive + * device identifiers. + * @param instance A user-defined instance value. The callback + * function will receive the same value. + * @retval result_t The status code. + * + * @assert + * @code callback != NULL @endcode */ -typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid); typedef result_t (*pmplib_enumerate_devid_t)(pmplib_enumerate_devid_callback_t callback, void *instance); +/** + * @} + */ + +/** + * \addtogroup pmp_driver Driver utility API + * @{ + */ + +/** + * Increment a variable value and check the resultant value. + * + * This function prevents more than one thread from using + * pmplib_interlocked_increment() or pmplib_interlocked_decrement() function + * to access the same variable simultaneously. + * + * @param count The pointer to the variable whose value is to be + * increased. + * @retval uint32_t The value of the variable after this increment. + */ PMPAPI uint32_t pmplib_interlocked_increment(uint32_t* count); + +/** + * Decrement a variable value and check the resultant value. + * + * This function prevents more than one thread from using + * pmplib_interlocked_increment() or pmplib_interlocked_decrement() function + * to access the same variable simultaneously. + * + * @param count The pointer to the variable whose value is to be + * decreased. + * @retval uint32_t The value of the variable after this decrement. + */ PMPAPI uint32_t pmplib_interlocked_decrement(uint32_t* count); +/** + * @} + */ @@ -671,8 +820,8 @@ * the device connected to the mount point (Win32 path "D:\"): * * @code - * #include <ucs2char.h> - * #include <pmp.h> + * #include <pmplib/ucs2char.h> + * #include <pmplib/pmp.h> * * int main(int argc, char *argv[]) * { Modified: trunk/pmplib/lib/filepath/filepath.vcproj =================================================================== --- trunk/pmplib/lib/filepath/filepath.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/filepath/filepath.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -159,7 +159,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath="..\..\include\filepath.h" + RelativePath="..\..\include\pmplib\filepath.h" > </File> </Filter> Modified: trunk/pmplib/lib/pmp/pmp.vcproj =================================================================== --- trunk/pmplib/lib/pmp/pmp.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp/pmp.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -204,7 +204,7 @@ > </File> <File - RelativePath="..\..\include\pmp.h" + RelativePath="..\..\include\pmplib\pmp.h" > </File> </Filter> Modified: trunk/pmplib/lib/pmp/pmp_win32.c =================================================================== --- trunk/pmplib/lib/pmp/pmp_win32.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp/pmp_win32.c 2007-02-09 16:13:11 UTC (rev 320) @@ -116,13 +116,13 @@ result_t pmplib_create(pmplib_t* pmplib, pmp_t** pmp, const ucs2char_t* path_to_device, const char *id) { uint32_t i; - result_t ret = PMP_DEVICENOTFOUND; + result_t ret = PMPERR_DEVICENOTFOUND; for (i = 0;i < pmplib->num_plugins;++i) { pmplib_create_t func = (pmplib_create_t)GetProcAddress(pmplib->plugins[i], "pmp_create"); if (func) { ret = func(pmp, path_to_device, id); - if (ret != PMP_DEVICENOTFOUND) { + if (ret != PMPERR_DEVICENOTFOUND) { return ret; } } Modified: trunk/pmplib/lib/pmp_iriverplus2/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/idx.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/idx.c 2007-02-09 16:13:11 UTC (rev 320) @@ -153,7 +153,7 @@ /* Check key type. */ if (idxkey->type < IP2DBIDX_PAGE_NODE_ENTRYNUMBER || IP2DBIDX_PAGE_NODE_FORMAT < idxkey->type) { - return PMPDBE_INVALIDTYPE; + return PMPERR_INCONSISTENCY; } *leafid = 0; @@ -172,14 +172,14 @@ ret = 0; } else { *leafid = 0; - ret = PMPDBE_NOTFOUND; + ret = PMPERR_ENTRYNOTFOUND; } break; } else { node = child; } } else { - ret = PMPDBE_NOTFOUND; + ret = PMPERR_ENTRYNOTFOUND; break; /* Not found. */ } } Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-09 16:13:11 UTC (rev 320) @@ -76,7 +76,7 @@ // Read dat. fp = ucs2fopen(dat_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbdat_read(db, fp); if (ret != 0) { @@ -88,7 +88,7 @@ // Read idx. fp = ucs2fopen(idx_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbidx_read(db, fp); if (ret != 0) { @@ -110,7 +110,7 @@ filepath_removefile(dat_filename); fp = ucs2fopen(dat_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbdat_write(db, fp); if (ret != 0) { @@ -123,7 +123,7 @@ filepath_removefile(idx_filename); fp = ucs2fopen(idx_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = ip2dbidx_write(db, fp); if (ret != 0) { @@ -175,7 +175,7 @@ // Allocate IP2DB records. ip2db_records = (ip2db_record_t*)calloc(n, sizeof(ip2db_record_t)); if (!ip2db_records) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -257,7 +257,7 @@ if (*num_records < n) { *num_records = n; - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } for (i = 1, j = 0;i <= n;++i) { // recid starts at 1. @@ -355,7 +355,7 @@ /* Check if the leafid is valid. */ if (recid < 1 || ip2db_get_num_record(db) < recid) { - return PMPDBE_INVALIDLEAFID; + return PMPERR_INCONSISTENCY; } /* Fill the record from an element of dat array. */ Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db_dat.c 2007-02-09 16:13:11 UTC (rev 320) @@ -66,7 +66,7 @@ db->dat_size = num_records; if (!db->dat_array) { db->dat_size = 0; - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Just set records. @@ -116,7 +116,7 @@ uint8_t *p = NULL; uint8_t *dat_buffer = malloc(DAT_SIZE_PER_RECORD * db->dat_size); if (!dat_buffer) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } p = dat_buffer; Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db_idx.c 2007-02-09 16:13:11 UTC (rev 320) @@ -50,12 +50,12 @@ if (!sortitems) { free(idxkeys); free(sortitems); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } if (!idxkeys) { free(idxkeys); free(sortitems); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (type = IP2DBIDX_PAGE_NODE_ENTRYNUMBER;type <= IP2DBIDX_PAGE_NODE_FORMAT;++type) { Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-09 16:13:11 UTC (rev 320) @@ -349,13 +349,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -368,7 +368,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -444,13 +444,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } ip2db_init(&pmpmi->ip2db); @@ -543,7 +543,7 @@ pmp->info.path_to_playlist, plp_ext ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -579,7 +579,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-09 16:13:11 UTC (rev 320) @@ -345,13 +345,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -364,7 +364,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -440,13 +440,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } ip3db_init(&pmpmi->ip3db); @@ -656,7 +656,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } @@ -664,7 +664,7 @@ { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; if (level > 0) { - return PMP_NOTIMPLIMENTED; + return PMPERR_NOTIMPLIMENTED; //return ip2db_repr(&pmpdbi->ip2db, fp); } else { return ip3db_dump(&pmpmi->ip3db, fp); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-09 16:13:11 UTC (rev 320) @@ -176,13 +176,13 @@ // Fail if this library does not support the player. if (model == MODEL_NONE) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Create a PMP instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Set member methods. @@ -196,7 +196,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { pmp_release(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->instance = pmpi; @@ -310,13 +310,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } irivnavi_init(&pmpmi->db); @@ -363,24 +363,24 @@ ucs2cat(filename, ucs2cs_irivnavi_idb); fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } // Obtain the stream size. if (fseek(fp, 0, SEEK_END) != 0) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } if ((size = ftell(fp)) == -1) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } if (fseek(fp, 0, SEEK_SET) != 0) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } // Allocate a buffer that stores the whole data. buffer = (uint8_t*)malloc(size); if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; + ret = PMPERR_INSUFFICIENTMEMORY; goto error_exit; } @@ -389,7 +389,7 @@ // Read the data from the buffer. if (irivnavi_serialize(&pmpmi->db, buffer, 0) == 0) { - ret = PMPDBE_DBINCONSIST; + ret = PMPERR_INCONSISTENCY; goto error_exit; } @@ -464,7 +464,7 @@ // Initialize the record array. if (irivnavi_init_records(&pmpmi->db, pmpmi->num_records) != 0) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -493,7 +493,7 @@ filepath_removefile(filename); fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } irivnavi_update(&pmpmi->db); @@ -501,13 +501,13 @@ // Allocate a buffer that stores the whole data. buffer = (uint8_t*)malloc(pmpmi->db.size); if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; + ret = PMPERR_INSUFFICIENTMEMORY; goto error_exit; } // Write the data to the buffer. if (irivnavi_serialize(&pmpmi->db, buffer, 1) == 0) { - ret = PMPDBE_DBINCONSIST; + ret = PMPERR_INCONSISTENCY; goto error_exit; } @@ -539,7 +539,7 @@ pl->num_entries, path_to_root ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -580,7 +580,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-02-09 16:13:11 UTC (rev 320) @@ -489,13 +489,13 @@ } } if (!md->id) { - return PMP_DEVICENOTFOUND; + return PMPERR_DEVICENOTFOUND; } // Allocate PMP class instance. pmp = (pmp_t*)calloc(1, sizeof(pmp_t)); if (!pmp) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmp->add_ref = pmp_add_ref; @@ -508,7 +508,7 @@ pmpi = (pmp_internal_t*)calloc(1, sizeof(pmp_internal_t)); if (!pmpi) { free(pmp); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpi->decl = md; @@ -584,13 +584,13 @@ music = calloc(1, sizeof(pmp_music_t)); if (!music) { - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pmpmi = calloc(1, sizeof(pmp_music_internal_t)); if (!pmpmi) { free(music); - return PMPDBE_OUTOFMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } pp1db_init(&pmpmi->pp1db, pmpi->decl->hdr_initproc); @@ -681,7 +681,7 @@ pmp->info.path_to_playlist, plp_ext ) != 0) { - return PMPPLE_WRITE; + return PMPERR_WRITE; } } } @@ -717,7 +717,7 @@ pmplib_records_clone(records, pmpmi->records, pmpmi->num_records); return 0; } else { - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } } Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-09 16:13:11 UTC (rev 320) @@ -98,13 +98,13 @@ uint32_t i, j; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } // Read hdr. fp = ucs2fopen(hdr_filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -129,7 +129,7 @@ fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -139,7 +139,7 @@ db->dat = calloc(db->hdr->num_dat_entries, sizeof(dat_t)); if (!db->dat) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (j = 0;j < db->hdr->num_dat_entries;++j) { uint8_t *p = &buffer[db->hdr->dat_record_offset[j]]; @@ -153,7 +153,7 @@ ) <= 0) { free(buffer); fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } } free(buffer); @@ -163,7 +163,7 @@ db->idx = (idx_t**)calloc(db->hdr->num_dat_fields, sizeof(idx_t*)); if (!db->idx) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Read indices. @@ -178,7 +178,7 @@ fp = ucs2fopen(filename, "rb"); if (!fp) { - return PMPDBE_OPENFORREAD; + return PMPERR_OPENFORREAD; } ret = fread_all(fp, &buffer, &size); if (ret != 0) { @@ -189,7 +189,7 @@ db->idx[i] = calloc(db->hdr->num_dat_entries, sizeof(idx_t)); if (!db->idx[i]) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } for (j = 0;j < db->hdr->num_dat_entries;++j) { p += idx_serialize(p, &db->idx[i][j], 0); @@ -213,7 +213,7 @@ uint32_t offset = 0; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } // Write indices. @@ -227,13 +227,13 @@ fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } buffer = calloc(db->hdr->num_dat_entries, sizeof(idx_t)); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } p = buffer; @@ -254,12 +254,12 @@ fp = ucs2fopen(filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } p = buffer = calloc(db->hdr->num_dat_entries, field_descriptor_get_max_record_size(db->hdr)); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } offset = 0; db->hdr->dat_record_offset[0] = offset; @@ -285,12 +285,12 @@ // Read hdr. fp = ucs2fopen(hdr_filename, "wb"); if (!fp) { - return PMPDBE_OPENFORWRITE; + return PMPERR_OPENFORWRITE; } buffer = calloc(db->hdr->param.size, 1); if (!buffer) { fclose(fp); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } hdr_serialize(buffer, db->hdr, 1); fwrite(buffer, 1, db->hdr->param.size, fp); @@ -305,7 +305,7 @@ uint32_t i, j; if (!db->hdr) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } hdr_repr(db->hdr, fp); @@ -458,7 +458,7 @@ sort_item_t* si = NULL; if (!db->hdr) { - return PMPDBE_NOTINITIALIZED; + return PMPERR_INCONSISTENCY; } dat_free_array(db->dat, db->hdr); @@ -474,7 +474,7 @@ db->dat = calloc(n, sizeof(dat_t)); if (!db->dat) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Convert records from pmp_music_record_t to ip2db_record_t. @@ -498,7 +498,7 @@ si = calloc(n, sizeof(sort_item_t)); if (!si) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Generate indices. @@ -509,7 +509,7 @@ db->idx[i] = calloc(n, sizeof(idx_t)); if (!db->idx[i]) { pp1db_finish(db); - return PMP_INSUFFICIENTMEMORY; + return PMPERR_INSUFFICIENTMEMORY; } // Preparation for sorting records. @@ -562,7 +562,7 @@ // Check database consistency. if (db->hdr->num_dat_entries - db->hdr->num_dat_inactive_entries != n) { - return PMPDBE_DBINCONSIST; + return PMPERR_INCONSISTENCY; } if (!records) { @@ -572,7 +572,7 @@ if (*num_records < n) { *num_records = n; - return PMPDBE_INSUFFICIENT; + return PMPERR_INSUFFICIENTMEMORY; } for (i = 0, j = 0;i < db->hdr->num_dat_entries;++i) { Modified: trunk/pmplib/lib/ucs2/ucs2.vcproj =================================================================== --- trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-02-09 05:11:59 UTC (rev 319) +++ trunk/pmplib/lib/ucs2/ucs2.vcproj 2007-02-09 16:13:11 UTC (rev 320) @@ -163,7 +163,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath="..\..\include\ucs2char.h" + RelativePath="..\..\include\pmplib\ucs2char.h" > </File> </Filter> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-10 04:58:08
|
Revision: 323 http://svn.sourceforge.net/pmplib/?rev=323&view=rev Author: nyaochi Date: 2007-02-09 20:58:08 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Notify empty artist or album names as a player might move such entries to "unknown" section. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/common/easypmp.h trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-02-10 04:58:08 UTC (rev 323) @@ -209,7 +209,7 @@ ++num_obtained; } else { // Report the error. - if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_WARN_GMI, i, 0, filename) != 0) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_WARN_FAILURE, i, 0, filename) != 0) { result = EASYPMPE_CANCEL; goto error_exit; } @@ -217,6 +217,14 @@ record->ts_update = timestamp; record->ts_import = ts_import; } + + // Warn empty artist or album name. + if (!record->artist || !*record->artist || !record->album || !*record->album) { + if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_WARN_EMPTY, i, 0, filename) != 0) { + result = EASYPMPE_CANCEL; + goto error_exit; + } + } } if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_END, num_obtained, 0, NULL) != 0) { result = EASYPMPE_CANCEL; Modified: trunk/pmplib/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-02-10 04:58:08 UTC (rev 323) @@ -47,15 +47,16 @@ EASYPMPSP_START = 0x00000001, EASYPMPSP_PROGRESS = 0x00000002, EASYPMPSP_SKIPPED = 0x00000003, - EASYPMPSP_WARN_GMI = 0x00000004, - EASYPMPSP_WARN_PLAYLIST = 0x00000005, - EASYPMPSP_SKIP_PLAYLIST = 0x00000006, - EASYPMPSP_MISSING_MEDIA = 0x00000007, - EASYPMPSP_JSPL_ERROR = 0x00000008, - EASYPMPSP_JSPL_ERROR_POS = 0x00000009, - EASYPMPSP_JSPL_ERROR_LINE = 0x0000000A, - EASYPMPSP_JSPL_OUTPUT = 0x0000000B, - EASYPMPSP_END = 0x0000000C, + EASYPMPSP_WARN_FAILURE = 0x00000004, + EASYPMPSP_WARN_EMPTY = 0x00000005, + EASYPMPSP_WARN_PLAYLIST = 0x00000006, + EASYPMPSP_SKIP_PLAYLIST = 0x00000007, + EASYPMPSP_MISSING_MEDIA = 0x00000008, + EASYPMPSP_JSPL_ERROR = 0x00000009, + EASYPMPSP_JSPL_ERROR_POS = 0x0000000A, + EASYPMPSP_JSPL_ERROR_LINE = 0x0000000B, + EASYPMPSP_JSPL_OUTPUT = 0x0000000C, + EASYPMPSP_END = 0x0000000D, }; enum { Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-10 04:58:08 UTC (rev 323) @@ -114,11 +114,16 @@ case EASYPMPP_MUSIC_GMI|EASYPMPSP_PROGRESS: easypmp_progress_num_str(fpo, param_int+1, filepath_skippath(param_str)); break; - case EASYPMPP_MUSIC_GMI|EASYPMPSP_WARN_GMI: + case EASYPMPP_MUSIC_GMI|EASYPMPSP_WARN_FAILURE: console_clearln(fpo); fprintf(fpe, " WARNING: Could not obtain the media information\n"); fprints(fpe, " %s\n", param_str); break; + case EASYPMPP_MUSIC_GMI|EASYPMPSP_WARN_EMPTY: + console_clearln(fpo); + fprintf(fpe, " WARNING: Empty artist or album name found\n"); + fprints(fpe, " %s\n", param_str); + break; case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: console_clearln(fpo); fprintf(fpo, " %d files were imported\n", param_int); Modified: trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/frontend/easypmp/win32gui/processingdlg.h 2007-02-10 04:58:08 UTC (rev 323) @@ -568,6 +568,14 @@ dlg->m_ctrlProgress.SetPos(param_int); dlg->write_log(LL_TRACE, _T("%s"), UCS2CT(param_str)); break; + case EASYPMPP_MUSIC_GMI|EASYPMPSP_WARN_FAILURE: + dlg->m_bFailed = TRUE; + dlg->write_log(LL_WARNING, _T("WARNING: Could not obtain the media information: %s"), UCS2CT(param_str)); + break; + case EASYPMPP_MUSIC_GMI|EASYPMPSP_WARN_EMPTY: + dlg->m_bFailed = TRUE; + dlg->write_log(LL_WARNING, _T("WARNING: Empty artist or album name found: %s"), UCS2CT(param_str)); + break; case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: dlg->m_ctrlProgress.ShowWindow(SW_HIDE); //dlg->m_ctrlProgress.DestroyWindow(); Modified: trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-02-10 04:58:08 UTC (rev 323) @@ -228,7 +228,7 @@ } *p++ = 0; //strcpy(model->name, line); - strcpy(model->name, "iRiver H10"); + strcpy(model->name, "H10"); // Parse and check version number. q = strchr(p, '-'); Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-02-10 04:38:49 UTC (rev 322) +++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-02-10 04:58:08 UTC (rev 323) @@ -203,7 +203,7 @@ } // Obtain the model name. - strcpy(model->name, "MSI MEGA PLAYER 540"); + strcpy(model->name, "MEGA PLAYER 540"); memset(model->version, 0, sizeof(model->version)); strncpy(model->version, buff+0x1F, 8); strcpy(model->language, ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-02-10 17:21:13
|
Revision: 326 http://svn.sourceforge.net/pmplib/?rev=326&view=rev Author: nyaochi Date: 2007-02-10 09:21:12 -0800 (Sat, 10 Feb 2007) Log Message: ----------- Fix update mode for pmp_iriverplus2 Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-10 15:23:26 UTC (rev 325) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-10 17:21:12 UTC (rev 326) @@ -306,7 +306,7 @@ // Create a PMP instance. res = pmplib_create(pmplib, &pmp, opt.path_to_root, opt.model); if (!pmp) { - fprintf(fpe, "ERROR: Failed to find a player (%d)\n", res); + fprintf(fpe, "ERROR: Failed to find a player (%X)\n", res); ret = 1; goto exit_main; } @@ -340,7 +340,7 @@ } res = pmp->open(pmp, openflag); if (res) { - fprintf(fpe, "ERROR: Failed to open the player (%d)\n", res); + fprintf(fpe, "ERROR: Failed to open the player (%X)\n", res); ret = 1; goto exit_main; } @@ -406,7 +406,7 @@ } res = pmp->close(pmp); if (res) { - fprintf(fpe, "ERROR: Failed to close the player (%d)\n", res); + fprintf(fpe, "ERROR: Failed to close the player (%X)\n", res); ret = 1; goto exit_main; } Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-10 15:23:26 UTC (rev 325) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-02-10 17:21:12 UTC (rev 326) @@ -452,8 +452,6 @@ free(music); return PMPERR_INSUFFICIENTMEMORY; } - ip2db_init(&pmpmi->ip2db); - music->set_records = pmpmusic_set_records; music->get_records = pmpmusic_get_records; music->dump = pmpmusic_dump; @@ -473,7 +471,6 @@ static uint32_t pmpmusic_release(pmp_music_t* music) { pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; - ip2db_finish(&pmpmi->ip2db); pmplib_records_finish(pmpmi->records, pmpmi->num_records); free(pmpmi->playlists); free(pmpmi); @@ -497,6 +494,9 @@ ucs2char_t sys[MAX_PATH], dat[MAX_PATH], idx[MAX_PATH]; pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Initialize IP2DB. + ip2db_init(&pmpmi->ip2db); + // Read the music database. set_filenames(sys, dat, idx, pmp); ret = ip2db_read(&pmpmi->ip2db, dat, idx); @@ -516,7 +516,15 @@ return PMPERR_INSUFFICIENTMEMORY; } - return ip2db_get(&pmpmi->ip2db, pmpmi->records, &pmpmi->num_records, pmp->info.path_to_root); + ret = ip2db_get(&pmpmi->ip2db, pmpmi->records, &pmpmi->num_records, pmp->info.path_to_root); + if (ret) { + return ret; + } + + // Finish the IP2DB. + ip2db_finish(&pmpmi->ip2db); + + return ret; } return 0; @@ -532,6 +540,9 @@ if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { ucs2char_t sys[MAX_PATH], dat[MAX_PATH], idx[MAX_PATH]; + // Initialize IP2DB. + ip2db_init(&pmpmi->ip2db); + ip2db_set(&pmpmi->ip2db, pmpmi->records, pmpmi->num_records, pmp->info.path_to_root); set_filenames(sys, dat, idx, pmp); @@ -560,6 +571,9 @@ } } + // Finish the IP2DB. + ip2db_finish(&pmpmi->ip2db); + return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |