You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(56) |
Jul
(101) |
Aug
(14) |
Sep
|
Oct
(1) |
Nov
|
Dec
(40) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(66) |
Feb
(106) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(10) |
Oct
(7) |
Nov
|
Dec
|
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
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 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 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 04:06:44
|
Revision: 297 http://svn.sourceforge.net/pmplib/?rev=297&view=rev Author: nyaochi Date: 2007-02-05 20:06:42 -0800 (Mon, 05 Feb 2007) Log Message: ----------- More work on API restructuring. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/database.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/include/filepath.h trunk/pmplib/include/gmi.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/gmi/gmi_mp3.c trunk/pmplib/lib/gmi/gmi_vorbis.c trunk/pmplib/lib/gmi/gmi_wav.c trunk/pmplib/lib/gmi/gmi_wma.c trunk/pmplib/lib/playlist/jspl.c trunk/pmplib/lib/pmp_portalplayer1/pp1db.c trunk/pmplib/lib/ucs2/ucs2char.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c trunk/pmplib/lib/ucs2/ucs2char_win32.c Modified: trunk/pmplib/frontend/easypmp/common/database.c =================================================================== --- trunk/pmplib/frontend/easypmp/common/database.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/frontend/easypmp/common/database.c 2007-02-06 04:06:42 UTC (rev 297) @@ -169,7 +169,7 @@ uint32_t timestamp = 0; filepath_combinepath(filename, MAX_PATH, target->pathname, target->filename); - timestamp = (uint32_t)ucs2stat_mtime(filename); + timestamp = (uint32_t)filepath_mtime(filename); // Report the progress. if (progress(instance, EASYPMPP_MUSIC_GMI | EASYPMPSP_PROGRESS, i, 0, filename) != 0) { @@ -202,6 +202,7 @@ filename, music_path, opt->media_info_source, + opt->music_encoding, opt->strip_words, opt->num_strip_words ) == 0) { Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-06 04:06:42 UTC (rev 297) @@ -36,10 +36,6 @@ #include <direct.h> /* getcwd() */ #endif/*_MSC_VER*/ -#ifdef HAVE_LANGINFO_CODESET -#include <langinfo.h> -#endif - #include <ucs2char.h> #include <filepath.h> #include <gmi.h> @@ -106,25 +102,13 @@ fprintf(fp, " -h, --help Show this help message and exit\n"); } -static char *get_default_encoding() -{ - const char *encoding = getenv("CHARSET"); - -#ifdef HAVE_LANGINFO_CODESET - if (!encoding) { - encoding = nl_langinfo(CODESET); - } -#endif - return encoding ? strdup(encoding) : strdup("UTF-8"); -} - void option_init(option_t* opt) { memset(opt, 0, sizeof(*opt)); // Set default values here. opt->media_info_source = GMIF_TAG; - opt->system_encoding = get_default_encoding(); + opt->system_encoding = strdup(ucs2getenc()); opt->music_encoding = strdup("ISO-8859-1"); } Modified: trunk/pmplib/include/filepath.h =================================================================== --- trunk/pmplib/include/filepath.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/filepath.h 2007-02-06 04:06:42 UTC (rev 297) @@ -82,6 +82,12 @@ 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 } #endif/*__cplusplus*/ Modified: trunk/pmplib/include/gmi.h =================================================================== --- trunk/pmplib/include/gmi.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/gmi.h 2007-02-06 04:06:42 UTC (rev 297) @@ -62,6 +62,7 @@ const ucs2char_t *filename, const ucs2char_t* path_to_music, int flag, + const char *charset, ucs2char_t **strip_words, int num_strip_words ); Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/include/ucs2char.h 2007-02-06 04:06:42 UTC (rev 297) @@ -38,8 +38,17 @@ #endif/*__cplusplus*/ /** - * \addtogroup ucs2 PMPlib UCS-2 API. - * @{ + * \addtogroup ucs2 UCS-2 Character/String API + * @{ + * + * The PMPlib UCS-2 character/string API provides a manupulation utility + * for characters/strings in UCS-2 encoding. As a number of portable media + * players support Unicode for displaying song information, PMPlib deals + * with Unicode characters/strings encoded in UCS-2. + * + * The byte order of UCS-2 character is dependent on the CPU architecture + * on which this code runs: e.g., little-endian on Intel IA-32/IA-64 and + * big-endian on IBM PowerPC. */ /** @@ -47,35 +56,241 @@ */ typedef uint16_t ucs2char_t; +/** + * Initialize the UCS-2 library. + * + * This function initializes internal variables used in the UCS-2 library. + * Call this function before using any other functions in this API. + * + * @retval int Zero if succeeded, otherwise non-zero value. + */ +UCS2API int ucs2init(); +/** + * @defgroup ucs2_conv Character encoding converter + * @{ + * + * This API subset converts the character encoding of a string from one to + * another. It supports mutual conversions between: + * UCS-2 and multi-byte character (i.e., \c char); + * UCS-2 and UTF-8. + * + * By default, this library detects the character encoding of multi-byte + * characters on the current system based on the value of LANG variable + * (for POSIX) or via GetACP() function (for Win32). + */ /** - * @defgroup ucs2_conv Charaset conversion routines. - * @{ + * Set the encoding for multi-byte characters (for iconv/libiconv). + * + * This function change the default encoding for multi-byte characters to the + * character encoding specified by the \a encoding argument. + * + * @param encoding The pointer to the string specifying the character + * encoding. + * + * @note + * This function is effective only on environments with iconv (libiconv). */ +UCS2API int ucs2setenc(const char *encoding); -struct tag_ucs2conv { - const char *from; - const char *to; -}; -typedef struct tag_ucs2conv ucs2conv_t; +/** + * Get the encoding for multi-byte characters (for iconv/libiconv). + * + * This function returns the default encoding for multi-byte characters used + * in the UCS-2 API. + * + * @retval const char* The pointer to the string of the character encoding. + * + * @note + * This function is effective only on environments with iconv (libiconv). + */ +UCS2API const char *ucs2getenc(); -UCS2API int ucs2init(const char *encoding); +/** + * Set the code page for multi-byte characters (for Win32). + * + * This function change the default encoding for multi-byte characters to the + * code page specified by the \a cp argument. + * + * @param cp The code page. + * + * @note + * This function is effective only on Win32 environments. + */ +UCS2API void ucs2setcp(int cp); -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); +/** + * Get the code page for multi-byte characters (for Win32). + * + * This function returns the default code page for multi-byte characters. + * + * @param cp The code page. + * + * @note + * This function is effective only on Win32 environments. + */ +UCS2API int ucs2getcp(); +/** + * Convert a UCS-2 string to multi-byte characters. + * + * @param mbstr The pointer to the buffer for receiving multi-byte + * characters converted from the UCS-2 string. If + * \a mbs_size is zero, this argument is not be used. + * @param mbs_size The size, in bytes, of the buffer pointed to by the + * \a mbstr argument. If this value is zero, the function + * returns the number of bytes required for the buffer. + * @param ucs2str The pointer to the UCS-2 string to be converted. + * @param ucs_size The size, in number of UCS-2 characters, of the UCS-2 + * string, \a ucs2str. + * @retval size_t The number of bytes written to \a mbstr buffer if + * the conversion is successful. If \a mbs_size is zero, + * the return value is the required size, in bytes, for a + * buffer to receive the converted string. This function + * returns zero if an error occurred. + */ UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); + +/** + * Convert multi-byte characters to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the multi-byte characters. If + * \a ucs_size is zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the multi-byte characters to be + * converted. + * @param mbs_size The size, in bytes, of the multi-byte characters, + * \a mbstr. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + */ 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); + +/** + * Convert multi-byte characters in a specific encoding to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the multi-byte characters. If + * \a ucs_size is zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the multi-byte characters to be + * converted. + * @param mbs_size The size, in bytes, of the multi-byte characters, + * \a mbstr. + * @param charset The pointer to the string specifying the encoding of + * the multi-byte characters. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + * @note + * \a charset is ignored on Win32 environments. + */ +UCS2API size_t mbstoucs2_charset(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size, const char *charset); + +/** + * Convert a UCS-2 string to multi-byte characters. + * + * @param mbstr The pointer to the buffer for receiving UTF-8 string + * converted from the UCS-2 string. If \a mbs_size is + * zero, this argument is not be used. + * @param mbs_size The size, in bytes, of the buffer pointed to by the + * \a mbstr argument. If this value is zero, the function + * returns the number of bytes required for the buffer. + * @param ucs2str The pointer to the UCS-2 string to be converted. + * @param ucs_size The size, in number of UCS-2 characters, of the UCS-2 + * string, \a ucs2str. + * @retval size_t The number of bytes written to \a mbstr buffer if + * the conversion is successful. If \a mbs_size is zero, + * the return value is the required size, in bytes, for a + * buffer to receive the converted string. This function + * returns zero if an error occurred. + */ +UCS2API size_t ucs2toutf8(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); + +/** + * Convert a UTF-8 string to a UCS-2 string. + * + * @param ucs2str The pointer to the buffer for receiving UCS-2 string + * converted from the UTF-8 string. If \a ucs_size is + * zero, this argument is not be used. + * @param ucs_size The size, in number of UCS-2 characters, of the buffer + * pointed to by the \a ucs2str argument. If this value is + * zero, the function returns the number of UCS-2 + * characters required for the buffer. + * @param mbstr The pointer to the UTF-8 string to be converted. + * @param mbs_size The size, in bytes, of the UTF-8 string, \a mbstr. + * @retval size_t The number of UCS-2 characters written to \a ucs2str + * buffer if the conversion is successful. If \a ucs_size + * is zero, the return value is the required size, in + * number of UCS-2 characters, for a buffer to receive the + * converted string. This function returns zero if an error + * occurred. + */ UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +/** + * Convert and duplicate a UCS-2 string to multi-byte characters. + * + * @param ucs2str The pointer to a UCS-2 string. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); + +/** + * Convert and duplicate multi-byte characters to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); + +/** + * Convert and duplicate multi-byte characters in a specific encoding + * to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @param charset The pointer to the string specifying the encoding of + * the multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API ucs2char_t* mbsdupucs2_charset(const char *mbstr, const char *charset); + +/** + * Convert and duplicate a UCS-2 string to a UTF-8 string. + * + * @param ucs2str The pointer to a UCS-2 string. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API char *ucs2duputf8(const ucs2char_t *ucs2str); + +/** + * Convert and duplicate a UTF-8 string to a UCS-2 string. + * + * @param mbstr The pointer to multi-byte characters. + * @retval char* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); -UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); -UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); /** * @} @@ -83,89 +298,324 @@ -UCS2API void ucs2big2little(ucs2char_t* value); - - /** - * @defgroup ucs2_memory Memory allocation routines. + * @defgroup ucs2_memory Memory manager routines * @{ */ +/** + * Allocate a memory block. + * + * @param size The size, in bytes, of the memory block. + * @retval void* The pointer to the allocated memory block. + */ UCS2API void *ucs2malloc(size_t size); + +/** + * Allocate a memory block with values initialized as zero. + * + * @param size The size, in bytes, of the memory block. + * @retval void* The pointer to the allocated memory block. + */ UCS2API void *ucs2calloc(size_t size); + +/** + * Resize a memory block. + * + * @param ptr The pointer to the memory block to be resized. + * @param size The size, in bytes, of the new memory block. + * @retval void* The pointer to the new memory block. + */ UCS2API void *ucs2realloc(void *ptr, size_t size); -UCS2API void ucs2free(void* str); +/** + * Free a memory block. + * + * @param ptr The pointer to the memory block to be freed. + */ +UCS2API void ucs2free(void* ptr); + /** * @} */ -UCS2API int is_ucs2surrogate(ucs2char_t c); -UCS2API int isucs2space(ucs2char_t c); -UCS2API int isucs2digit(ucs2char_t c); +/** + * @defgroup ucs2_char UCS-2 character routines + * @{ + */ +UCS2API int ucs2issurrogate(ucs2char_t c); +UCS2API int ucs2isspace(ucs2char_t c); +UCS2API int ucs2isdigit(ucs2char_t c); +UCS2API ucs2char_t ucs2lower(ucs2char_t c); +UCS2API ucs2char_t ucs2upper(ucs2char_t c); + +/** + * @} + */ + + + + + /** - * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @defgroup ucs2_string_ansi ANSI C compatible string routines * @{ + * + * This is the subset of the UCS-2 Character/String API that corresponds + * to string manupulation routines in the ANSI C standard. The following + * ANSI C functions are not defined in this subset: + * strcoll, strerror, strtok, strxfrm. */ +/** + * Concatenate two strings. + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @retval ucs2char_t* The pointer to the destination string. + */ UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); -UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); + +/** + * Search for the first occurrence of a character in a string. + * + * @param str The pointer to the string in which \a c is searched. + * @param c The target character. + * @retval ucs2char_t* The pointer to the character \a c in \a str, or \c NULL + * if \a c does not occur in \a str. + */ +UCS2API ucs2char_t* ucs2chr(const ucs2char_t* str, ucs2char_t c); + +/** + * Compare two strings. + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); + +/** + * Copy a string. + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @retval ucs2char_t* The pointer to the destination string. + */ 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* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count); + +/** + * Count the number of characters not appearing in a character set. + * + * @param str The pointer to a string. + * @param charset The pointer to a character set. + * @retval size_t The number of characters from the beginning of \a str + * in which any character in \a charset appear for the + * first time, or the length of \a str if such a character + * does not exist. + */ +UCS2API size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset); + +/** + * Count the length of a string. + * + * @param str The pointer to a string. + * @retval size_t The number of characters in \a str. + */ +UCS2API size_t ucs2len(const ucs2char_t* str); + +/** + * Concatenate two strings (no more than the maximum length). + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @param n The number of characters to be concatenated. + * @retval ucs2char_t* The pointer to the destination string. + */ +UCS2API ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t n); + +/** + * Compare two strings (no longer than the maximum length). + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @param n The number of characters to be compared. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ 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* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search); + +/** + * Copy a string (no more than the maximum length). + * + * @param dst The pointer to the destination of a string. + * @param src The pointer to the source of a string. + * @param n The number of characters to be copied. + * @retval ucs2char_t* The pointer to the destination string. + */ +UCS2API ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t n); + +/** + * Find a character in a string that belongs to a character set. + * + * @param str The pointer to the string where \a charset is searched. + * @param charset The pointer to a character set. + * @retval ucs2char_t* The pointer to the character in \a str that belongs + * to \a charset, or \c NULL if such a character does not + * exist. + */ +UCS2API ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *charset); + +/** + * Search for the last occurrence of a character in a string. + * + * @param str The pointer to the string in which \a c is searched. + * @param c The target character. + * @retval ucs2char_t* The pointer to the character \a c in \a str, or \c NULL + * if \a c does not occur in \a str. + */ UCS2API ucs2char_t* ucs2rchr(const ucs2char_t* string, ucs2char_t c); + +/** + * Find a character in a string that does not belong to a character set. + * + * @param str The pointer to the string where \a charset is searched. + * @param charset The pointer to a character set. + * @retval ucs2char_t* The pointer to the character in \a str that does not + * belong to \a charset, or \c NULL if such a character + * does not exist. + */ UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); -UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); +/** + * Find a substring in a string. + * + * @param str The pointer to the string where \a substr is searched. + * @param substr The pointer to the substring. + * @retval ucs2char_t* The pointer to the character where \a substr begins + * in \a str for the first time, or \c NULL if \a str + * does not contain \a substr. + */ +UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* substr); + /** - * @} + * @} */ + + + + /** - * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @defgroup ucs2_string_non_ansi Miscellaneous string routines * @{ */ +/** + * Duplicate a string. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ +UCS2API ucs2char_t* ucs2dup(const ucs2char_t* str); + +/** + * Duplicate a string no longer than the specified length. + * + * @param str The pointer to a string. + * @param length The maximum length of the duplicated string. + * @retval ucs2char_t* The pointer to the duplicated string. Call ucs2free() + * to free the memory block allocated by this function. + */ UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); + +/** + * Convert a string to lowercase. + * + * Given \a str argument, this function converts uppercase letters in the + * string to lowercase and overwrites the resultant string on the same buffer + * pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); + +/** + * Convert a string to uppercase. + * + * Given \a str argument, this function converts lowercase letters in the + * string to uppercase and overwrites the resultant string on the same buffer + * pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); + +/** + * Compare two strings incasesensitively. + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); + +/** + * Compare two strings incasesensitively (no longer than the maximum length). + * + * @param x The pointer to a string. + * @param y The pointer to another string. + * @param n The number of characters to be compared. + * @retval int A positive value if \a x is greater than \a y; + * a negative value if \a x is smaller than \a y; + * zero if \a x is identical to \a y. + */ UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); +/** + * Strip whitespace characters at the head and tail of a string. + * + * Given \a str argument, this function trims whilespace characters at the + * head and tail of the string and overwrites the resultant string on the + * same buffer pointed by the \a str argument. + * + * @param str The pointer to a string. + * @retval ucs2char_t* The pointer to the string, which is the same value as + * \a str. + */ +UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); + /** * @} */ -UCS2API ucs2char_t ucs2lower(ucs2char_t c); -UCS2API ucs2char_t ucs2upper(ucs2char_t c); +/** + * @defgroup ucs2_std Wrapper for stdio/stdlib routines + * @{ + */ - -UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); - - UCS2API int ucs2toi(const ucs2char_t* str); UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); - - -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); -UCS2API int ucs2stat_is_exist(const ucs2char_t *filename); - UCS2API ucs2char_t fputucs2c(ucs2char_t c, FILE *fp); UCS2API FILE *ucs2fopen(const ucs2char_t *filename, const char *mode); /** @} */ +/** @} */ + #ifdef __cplusplus } #endif/*__cplusplus*/ Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-06 04:06:42 UTC (rev 297) @@ -72,7 +72,7 @@ ucs2cpy(tmp, path); ucs2cat(tmp, filename); - if (!ucs2stat_is_dir(tmp)){ + if (!filepath_is_dir(tmp)){ callback(instance, path, filename); } } @@ -101,7 +101,7 @@ ucs2cpy(tmp, path); ucs2cat(tmp, filename); - if (ucs2stat_is_dir(tmp)){ + if (filepath_is_dir(tmp)){ filepath_addslash(tmp); find_file(tmp, recursive, callback, instance); } @@ -354,7 +354,7 @@ int filepath_file_exists(const ucs2char_t* path) { - return ucs2stat_is_exist(path); + return filepath_exist(path); } int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative) @@ -396,8 +396,8 @@ struct stat st1; struct stat st2; - time_t ret1 = ucs2stat_mtime(file1); - time_t ret2 = ucs2stat_mtime(file2); + time_t ret1 = filepath_mtime(file1); + time_t ret2 = filepath_mtime(file2); return (ret1 - ret2); } Modified: trunk/pmplib/lib/filepath/filepath_win32.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_win32.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-06 04:06:42 UTC (rev 297) @@ -27,6 +27,9 @@ #include <os.h> +#include <sys/types.h> +#include <sys/stat.h> + #include <windows.h> #include <shlwapi.h> @@ -234,3 +237,36 @@ /* Does nothing for WIN32. */ return 0; } + +time_t filepath_mtime(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return st.st_mtime; + } + return 0; +} + +uint32_t filepath_size(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return st.st_size; + } + return 0; +} + +int filepath_is_dir(const ucs2char_t *filename) +{ + int ret = 0; + struct _stat st; + ret = _wstat(filename, &st); + if (ret == 0) { + return ((st.st_mode & S_IFMT) == S_IFDIR); + } + return 0; +} Modified: trunk/pmplib/lib/gmi/gmi.c =================================================================== --- trunk/pmplib/lib/gmi/gmi.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi.c 2007-02-06 04:06:42 UTC (rev 297) @@ -37,20 +37,20 @@ * @{ */ -int gmi_mp3(media_info_t* info, const ucs2char_t *filename); +int gmi_mp3(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_mp3[] = {'.','m','p','3',0}; -int gmi_wma(media_info_t* info, const ucs2char_t *filename); +int gmi_wma(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_wma[] = {'.','w','m','a',0}; -int gmi_vorbis(media_info_t* info, const ucs2char_t *filename); +int gmi_vorbis(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_ogg[] = {'.','o','g','g',0}; -int gmi_wav(media_info_t* info, const ucs2char_t *filename); +int gmi_wav(media_info_t* info, const ucs2char_t *filename, const char *charset); static const ucs2char_t ucs2cs_ext_wav[] = {'.','w','a','v',0}; typedef struct { - int (*func)(media_info_t* info, const ucs2char_t *filename); + int (*func)(media_info_t* info, const ucs2char_t *filename, const char *charset); const ucs2char_t* ext; } gmi_exports_t; @@ -198,6 +198,7 @@ const ucs2char_t *filename, const ucs2char_t* path_to_music, int flag, + const char *charset, ucs2char_t **strip_words, int num_strip_words ) @@ -207,12 +208,12 @@ /* Set the pathname and filename. */ info->filename = ucs2dup(filename); - info->filesize = ucs2stat_size(filename); + info->filesize = filepath_size(filename); if (flag & GMIF_TAG) { while (exp->func) { if (filepath_hasext(filename, exp->ext)) { - if (exp->func(info, filename) == 0) { + if (exp->func(info, filename, charset) == 0) { ret = 0; break; } Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2007-02-06 04:06:42 UTC (rev 297) @@ -273,7 +273,7 @@ } -static ucs2char_t* get_frame_value(struct id3_tag *id3tag, const char *name) +static ucs2char_t* get_frame_value(struct id3_tag *id3tag, const char *name, const char *charset) { ucs2char_t* ret = NULL; const id3_ucs4_t *value = NULL; @@ -313,7 +313,7 @@ if (encoding == ID3_FIELD_TEXTENCODING_ISO_8859_1) { char *mbs = id3_ucs4_latin1duplicate(value); - ret = mbsdupucs2_music(mbs); /* MBS for music files. */ + ret = mbsdupucs2_charset(mbs, charset); /* MBS for music files. */ free(mbs); return ret; } else { @@ -324,7 +324,7 @@ } } -int gmi_mp3(media_info_t* info, const ucs2char_t *filename) +int gmi_mp3(media_info_t* info, const ucs2char_t *filename, const char *charset) { int i, num_tags = 0; mp3header_t mp3header; @@ -375,7 +375,7 @@ } /* Obtain track number first. */ - ucs2 = get_frame_value(id3tag, "TRCK"); + ucs2 = get_frame_value(id3tag, "TRCK", charset); if (ucs2 && *ucs2) { info->track_number = ucs2toi(ucs2); } else { @@ -384,7 +384,7 @@ ucs2free(ucs2); /* Obtain track title. */ - ucs2 = get_frame_value(id3tag, "TIT2"); + ucs2 = get_frame_value(id3tag, "TIT2", charset); if (ucs2 && *ucs2) { ucs2free(info->title); info->title = ucs2dup(ucs2); @@ -392,11 +392,11 @@ ucs2free(ucs2); /* Set artist field. */ - if (1) ucs2 = get_frame_value(id3tag, "TPE1"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE2"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE3"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE4"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TCOM"); + if (1) ucs2 = get_frame_value(id3tag, "TPE1", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE2", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE3", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TPE4", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TCOM", charset); if (ucs2 && *ucs2) { ucs2free(info->artist); info->artist = ucs2dup(ucs2); @@ -404,7 +404,7 @@ ucs2free(ucs2); /* Set composer field. */ - ucs2 = get_frame_value(id3tag, "TCOM"); + ucs2 = get_frame_value(id3tag, "TCOM", charset); if (ucs2 && *ucs2) { ucs2free(info->composer); info->composer = ucs2dup(ucs2); @@ -412,7 +412,7 @@ ucs2free(ucs2); /* Set album field. */ - ucs2 = get_frame_value(id3tag, "TALB"); + ucs2 = get_frame_value(id3tag, "TALB", charset); if (ucs2 && *ucs2) { ucs2free(info->album); info->album = ucs2dup(ucs2); @@ -423,7 +423,7 @@ * TCMP (compilation flag) handling for omnibus albums. * This patch was originally submitted by Espen Matheussen. */ - ucs2 = get_frame_value(id3tag, "TCMP"); + ucs2 = get_frame_value(id3tag, "TCMP", charset); if (ucs2 && *ucs2) { size_t length = 0; ucs2char_t* title = NULL; @@ -458,7 +458,7 @@ } /* Set genre field. */ - ucs2 = get_frame_value(id3tag, "TCON"); + ucs2 = get_frame_value(id3tag, "TCON", charset); if (ucs2 && *ucs2) { ucs2free(info->genre); info->genre = ucs2dup(ucs2); @@ -466,8 +466,8 @@ ucs2free(ucs2); /* Set year field. */ - if (1) ucs2 = get_frame_value(id3tag, "TYER"); - if (!ucs2) ucs2 = get_frame_value(id3tag, "TDRC"); + if (1) ucs2 = get_frame_value(id3tag, "TYER", charset); + if (!ucs2) ucs2 = get_frame_value(id3tag, "TDRC", charset); if (ucs2 && *ucs2) { ucs2free(info->date); info->date = ucs2dup(ucs2); Modified: trunk/pmplib/lib/gmi/gmi_vorbis.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_vorbis.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_vorbis.c 2007-02-06 04:06:42 UTC (rev 297) @@ -46,7 +46,7 @@ #define strncasecmp _strnicmp #endif -int gmi_vorbis(media_info_t* info, const ucs2char_t *filename) +int gmi_vorbis(media_info_t* info, const ucs2char_t *filename, const char *charset) { int i, ret = 0; long lval = 0; @@ -59,7 +59,7 @@ /* Set the pathname and filename. */ /* info->filename = ucs2dup(filename); - info->filesize = ucs2stat_size(filename); + info->filesize = filepath_size(filename); */ /* Open the target file. */ Modified: trunk/pmplib/lib/gmi/gmi_wav.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_wav.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_wav.c 2007-02-06 04:06:42 UTC (rev 297) @@ -77,7 +77,7 @@ -int parse_listinfo(media_info_t* info, FILE *fp, uint32_t chunksize) +int parse_listinfo(media_info_t* info, FILE *fp, uint32_t chunksize, const char *charset) { int ret = 0; char buffer[1024]; @@ -109,23 +109,23 @@ switch (ch.id) { case 0x44525049: /* "IPRD" */ ucs2free(info->album); - info->album = mbsdupucs2_music(buffer); + info->album = mbsdupucs2_charset(buffer, charset); break; case 0x4D414E49: /* "INAM" */ ucs2free(info->title); - info->title = mbsdupucs2_music(buffer); + info->title = mbsdupucs2_charset(buffer, charset); break; case 0x54524149: /* "IART" */ ucs2free(info->artist); - info->artist = mbsdupucs2_music(buffer); + info->artist = mbsdupucs2_charset(buffer, charset); break; case 0x524E4749: /* "IGNR" */ ucs2free(info->genre); - info->genre = mbsdupucs2_music(buffer); + info->genre = mbsdupucs2_charset(buffer, charset); break; case 0x44524349: /* "ICRD" */ ucs2free(info->date); - info->date = mbsdupucs2_music(buffer); + info->date = mbsdupucs2_charset(buffer, charset); break; case 0x6974726B: /* "itrk" */ info->track_number = atoi(buffer); @@ -147,7 +147,7 @@ } -int get_riff_audio_info(media_info_t* info, const ucs2char_t *filename) +int get_riff_audio_info(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; FILE *fp = NULL; @@ -235,7 +235,7 @@ goto get_riff_audio_info_error; } if (tmp32 == 0x4F464E49) { - ret |= parse_listinfo(info, fp, ch.size - 4); + ret |= parse_listinfo(info, fp, ch.size - 4, charset); if (ret != 0) { goto get_riff_audio_info_error; } @@ -254,11 +254,11 @@ return -1; } -int gmi_wav(media_info_t* info, const ucs2char_t *filename) +int gmi_wav(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; - ret = get_riff_audio_info(info, filename); + ret = get_riff_audio_info(info, filename, charset); if (ret == 0) { info->codec = PMPCODEC_WAV; } Modified: trunk/pmplib/lib/gmi/gmi_wma.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_wma.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/gmi/gmi_wma.c 2007-02-06 04:06:42 UTC (rev 297) @@ -130,14 +130,14 @@ /* Skip space. */ pos--; while (begin <= pos) { - if (!isucs2space(*pos)) { + if (!ucs2isspace(*pos)) { break; } pos--; } /* Skip digits. */ while (begin <= pos) { - if (!isucs2digit(*pos)) { + if (!ucs2isdigit(*pos)) { pos++; break; } @@ -507,7 +507,7 @@ return -1; } -int gmi_wma(media_info_t* info, const ucs2char_t *filename) +int gmi_wma(media_info_t* info, const ucs2char_t *filename, const char *charset) { int ret = 0; Modified: trunk/pmplib/lib/playlist/jspl.c =================================================================== --- trunk/pmplib/lib/playlist/jspl.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/playlist/jspl.c 2007-02-06 04:06:42 UTC (rev 297) @@ -448,7 +448,7 @@ mbsfilename = ucs2dupmbs(filename); /* Obtain the filesize. */ - filesize = ucs2stat_size(filename); + filesize = filepath_size(filename); /* Read the entire file at one time. */ buff = (char*)malloc(filesize+1); Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.c 2007-02-06 04:06:42 UTC (rev 297) @@ -414,6 +414,25 @@ return ret; } +static int is_bigendian(void) +{ + ucs2char_t c = 0x1234; + uint8_t* p = (uint8_t*)&c; + return (*p == 0x12); +} + +static void ucs2big2little(ucs2char_t* value) +{ + if (is_bigendian()) { + for (;*value;value++) { + ucs2char_t val = (*value << 8) | (*value >> 8); + *value = val; + } + } +} + + + static uint32_t ucs2crc(const ucs2char_t* value) { if (value) { Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-02-06 04:06:42 UTC (rev 297) @@ -59,17 +59,17 @@ free(str); } -int is_ucs2surrogate(ucs2char_t c) +int ucs2issurrogate(ucs2char_t c) { return (0xD800 <= c && c <= 0xDFFF); } -int isucs2space(ucs2char_t c) +int ucs2isspace(ucs2char_t c) { return ((0x0009 <= c && c <= 0x000D) || c == 0x0020); } -int isucs2digit(ucs2char_t c) +int ucs2isdigit(ucs2char_t c) { return (0x0030 <= c && c <= 0x0039); } @@ -299,14 +299,14 @@ if (str && *str) { ucs2char_t* p = NULL; for (p = str + ucs2len(str) - 1;str <= p;p--) { - if (!isucs2space(*p)) { + if (!ucs2isspace(*p)) { *(p + 1) = 0; break; } } for (p = str;p < str + ucs2len(str);p++) { - if (!isucs2space(*p)) { + if (!ucs2isspace(*p)) { break; } } @@ -381,12 +381,12 @@ return dst; } -ucs2char_t* mbsdupucs2_music(const char *mbstr) +ucs2char_t* mbsdupucs2_charset(const char *mbstr, const char *charset) { - size_t ucs2_size = mbstoucs2_music(NULL, 0, mbstr, strlen(mbstr)) + 1; + size_t ucs2_size = mbstoucs2_charset(NULL, 0, mbstr, strlen(mbstr), charset) + 1; ucs2char_t* dst = (ucs2char_t*)malloc(ucs2_size * sizeof(ucs2char_t)); if (dst) { - mbstoucs2_music(dst, ucs2_size * sizeof(ucs2char_t), mbstr, strlen(mbstr)+1); + mbstoucs2_charset(dst, ucs2_size * sizeof(ucs2char_t), mbstr, strlen(mbstr)+1, charset); } return dst; } Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-06 04:06:42 UTC (rev 297) @@ -39,11 +39,17 @@ #include <iconv.h> -/** - * \addtogroup ucs2 - * @{ - */ +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif + +struct tag_ucs2conv { + const char *from; + const char *to; +}; +typedef struct tag_ucs2conv ucs2conv_t; + #ifdef USE_LIBICONV_GNU #define iconv_open libiconv_open #define iconv_convert libiconv_convert @@ -57,9 +63,20 @@ #define MBS_CHARSET "UTF-8" static char g_encoding[128]; -static char g_encoding_music[128]; static char g_ucs2encoding[128]; +static char *get_default_encoding() +{ + const char *encoding = getenv("CHARSET"); + +#ifdef HAVE_LANGINFO_CODESET + if (!encoding) { + encoding = nl_langinfo(CODESET); + } +#endif + return encoding ? strdup(encoding) : strdup("UTF-8"); +} + static void print_ucs2(const ucs2char_t* str) { while (*str) { @@ -69,13 +86,6 @@ 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"; @@ -83,13 +93,12 @@ return is_bigendian() ? unicode_big : unicode_little; } -int ucs2init(const char *encoding) +int ucs2init() { if (!encoding) { encoding = MBS_CHARSET; } strcpy(g_encoding, encoding); - strcpy(g_encoding_music, encoding); } static int ucs2check(ucs2conv_t* conv) @@ -127,31 +136,16 @@ return 0; } -int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +int ucs2setenc(const char *encoding) { + int ret = 0; + ucs2conv_t conv; strncpy(g_encoding, encoding, sizeof(g_encoding)); strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); + 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()) { - for (;*value;value++) { - ucs2char_t val = (*value << 8) | (*value >> 8); - *value = val; - } - } -} - int ucs2toi(const ucs2char_t* str) { int ret; @@ -267,7 +261,7 @@ return fp; } -time_t ucs2stat_mtime(const ucs2char_t *filename) +time_t filepath_mtime(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -284,7 +278,7 @@ return 0; } -uint32_t ucs2stat_size(const ucs2char_t *filename) +uint32_t filepath_size(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -301,7 +295,7 @@ return 0; } -int ucs2stat_is_dir(const ucs2char_t *filename) +int filepath_is_dir(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -318,7 +312,7 @@ return 0; } -int ucs2stat_is_exist(const ucs2char_t *filename) +int filepath_exist(const ucs2char_t *filename) { int ret = 0; struct stat st; @@ -336,5 +330,3 @@ } return 0; } - -/** @} */ Modified: trunk/pmplib/lib/ucs2/ucs2char_win32.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-01-30 15:43:25 UTC (rev 296) +++ trunk/pmplib/lib/ucs2/ucs2char_win32.c 2007-02-06 04:06:42 UTC (rev 297) @@ -29,8 +29,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/stat.h> #include <ucs2char.h> #ifdef _WIN32 @@ -42,14 +40,16 @@ #endif static UINT g_codepage = CP_ACP; +static const char *g_encoding = ""; -void ucs2set_codepage(int cp) +void ucs2setcp(int cp) { g_codepage = (UINT)cp; } -void ucs2big2little(ucs2char_t* value) +UCS2API const char *ucs2getenc() { + return g_encoding; } int ucs2toi(const ucs2char_t* str) @@ -73,7 +73,7 @@ return MultiByteToWideChar(g_codepage, 0, mbstr, (int)mbs_len, ucs2str, (int)ucs_len); } -size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_len, const char *mbstr, size_t mbs_len) +size_t mbstoucs2_charset(ucs2char_t *ucs2str, size_t ucs_len, const char *mbstr, size_t mbs_len, const char *charset) { return MultiByteToWideChar(g_codepage, 0, mbstr, (int)mbs_len, ucs2str, (int)ucs_len); } @@ -120,36 +120,3 @@ } return fp; } - -time_t ucs2stat_mtime(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - if (ret == 0) { - return st.st_mtime; - } - return 0; -} - -uint32_t ucs2stat_size(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - if (ret == 0) { - return st.st_size; - } - return 0; -} - -int ucs2stat_is_dir(const ucs2char_t *filename) -{ - int ret = 0; - struct _stat st; - ret = _wstat(filename, &st); - 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-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-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-28 22:46:02
|
Revision: 294 http://svn.sourceforge.net/pmplib/?rev=294&view=rev Author: nyaochi Date: 2007-01-28 14:46:02 -0800 (Sun, 28 Jan 2007) Log Message: ----------- Moved back to the old code; let libid3tag to manage the file pointer opened for id3_file_fdopen(). I got a bug report from a user who seems to utilize a non-native UNICODE path/file name on Win32. Modified Paths: -------------- trunk/pmplib/lib/gmi/gmi_mp3.c Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-28 22:30:55 UTC (rev 293) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-28 22:46:02 UTC (rev 294) @@ -333,12 +333,18 @@ ucs2char_t* ucs2 = NULL; struct id3_file *id3file = NULL; struct id3_tag *id3tag = NULL; - char* pathname = ucs2dupmbs(filename); + FILE *fp = NULL; + /* 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_open(pathname, ID3_FILE_MODE_READONLY); - ucs2free(pathname); + id3file = id3_file_fdopen(fileno(fp), ID3_FILE_MODE_READONLY); if (!id3file) { + fclose(fp); return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-28 22:30:54
|
Revision: 293 http://svn.sourceforge.net/pmplib/?rev=293&view=rev Author: nyaochi Date: 2007-01-28 14:30:55 -0800 (Sun, 28 Jan 2007) Log Message: ----------- Applied two patches for libid3tag (crash fix; Win32 only): http://sourceforge.net/tracker/index.php?func=detail&aid=1407914&group_id=12349&atid=312349 http://sourceforge.net/tracker/index.php?func=detail&aid=1580869&group_id=12349&atid=312349 Modified Paths: -------------- trunk/pmplib/lib/gmi/contrib/id3tag/win32/libid3tag.lib trunk/pmplib/lib/gmi/contrib/id3tag/win32/libid3tagd.lib Modified: trunk/pmplib/lib/gmi/contrib/id3tag/win32/libid3tag.lib =================================================================== (Binary files differ) Modified: trunk/pmplib/lib/gmi/contrib/id3tag/win32/libid3tagd.lib =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-28 21:10:53
|
Revision: 292 http://svn.sourceforge.net/pmplib/?rev=292&view=rev Author: nyaochi Date: 2007-01-28 13:10:48 -0800 (Sun, 28 Jan 2007) Log Message: ----------- Changed the default value for -w option to ISO-8859-1. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/option.c Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-27 09:10:52 UTC (rev 291) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-01-28 21:10:48 UTC (rev 292) @@ -125,7 +125,7 @@ // Set default values here. opt->media_info_source = GMIF_TAG; opt->system_encoding = get_default_encoding(); - opt->music_encoding = get_default_encoding(); + opt->music_encoding = strdup("ISO-8859-1"); } void option_finish(option_t* opt) 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:10:54
|
Revision: 291 http://svn.sourceforge.net/pmplib/?rev=291&view=rev Author: nyaochi Date: 2007-01-27 01:10:52 -0800 (Sat, 27 Jan 2007) Log Message: ----------- Removed redundant compare_version() function in pmp_portalplayer1: http://nyaochi.sakura.ne.jp/pmplib/index.php?topic=210.msg910#msg910 Modified Paths: -------------- trunk/pmplib/lib/pmp_portalplayer1/hdr_template.c trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h Modified: trunk/pmplib/lib/pmp_portalplayer1/hdr_template.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/hdr_template.c 2007-01-27 09:03:05 UTC (rev 290) +++ trunk/pmplib/lib/pmp_portalplayer1/hdr_template.c 2007-01-27 09:10:52 UTC (rev 291) @@ -90,24 +90,3 @@ memset(hdr, 0, sizeof(*hdr)); return -1; } - -#define COMP(a, b) ((a)>(b))-((a)<(b)) - -int compare_version(const char *x, const char *y) -{ - char *p = NULL, *q = NULL; - - for (;;) { - long a = strtol(x, &p, 10); - long b = strtol(y, &q, 10); - int value = COMP(a, b); - if (value != 0) { - return value; - } - if (!*p || !*q || *p != *q) { - return COMP(*p, *q); - } - x = p+1; - y = q+1; - } -} Modified: trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h 2007-01-27 09:03:05 UTC (rev 290) +++ trunk/pmplib/lib/pmp_portalplayer1/hdr_template.h 2007-01-27 09:10:52 UTC (rev 291) @@ -57,7 +57,6 @@ } hdr_template_t; int apply_template(hdr_t* hdr, const hdr_template_t* tmpl); -int compare_version(const char *x, const char *y); int hdr_init_h10_5gb_ums_0205_0253(hdr_t* hdr); int hdr_init_h10_5gb_mtp_0203_0210(hdr_t* hdr); 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:03:07
|
Revision: 290 http://svn.sourceforge.net/pmplib/?rev=290&view=rev Author: nyaochi Date: 2007-01-27 01:03:05 -0800 (Sat, 27 Jan 2007) Log Message: ----------- Patch from jonof at the forum: http://nyaochi.sakura.ne.jp/pmplib/index.php?topic=210.msg910#msg910 Modified Paths: -------------- trunk/pmplib/lib/gmi/gmi_mp3.c Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-27 09:00:28 UTC (rev 289) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2007-01-27 09:03:05 UTC (rev 290) @@ -327,7 +327,6 @@ int gmi_mp3(media_info_t* info, const ucs2char_t *filename) { int i, num_tags = 0; - FILE *fp = NULL; mp3header_t mp3header; uint32_t tn = 0; static const ucs2char_t ucs2_empty[1] = {0}; @@ -340,7 +339,6 @@ id3file = id3_file_open(pathname, ID3_FILE_MODE_READONLY); ucs2free(pathname); if (!id3file) { - fclose(fp); return -1; } 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-26 15:59:23
|
Revision: 288 http://svn.sourceforge.net/pmplib/?rev=288&view=rev Author: nyaochi Date: 2007-01-26 07:59:23 -0800 (Fri, 26 Jan 2007) Log Message: ----------- Show supported audio codecs and extensions. Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/device.c trunk/pmplib/frontend/easypmp/cui/main.c Modified: trunk/pmplib/frontend/easypmp/cui/device.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-26 15:39:06 UTC (rev 287) +++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-01-26 15:59:23 UTC (rev 288) @@ -59,6 +59,8 @@ void device_show_information(pmp_t* pmp, FILE *fp) { + int i; + fprintf(fp, "Device identifier: %s\n", pmp->info.decl.id); fprintf(fp, " Manufacturer: %s\n", pmp->info.decl.manufacturer); fprintf(fp, " Product name: %s\n", pmp->info.decl.name); @@ -67,6 +69,25 @@ fprintf(fp, " Firmware range: %s to %s\n", pmp->info.decl.min_version, pmp->info.decl.max_version); fprintf(fp, " Default language: %s\n", pmp->info.decl.language); + fprintf(fp, " Audio codec(s): "); + for (i = 0;i < pmp->info.num_audio_codecs;++i) { + switch (pmp->info.audio_codecs[i]) { + case PMPCODEC_MPEGLAYER3: fputs("MP3", fp); break; + case PMPCODEC_WMA: fputs("WMA", fp); break; + case PMPCODEC_VORBIS: fputs("Ogg Vorbis", fp); break; + case PMPCODEC_WAV: fputs("WAV", fp); break; + } + if (i != pmp->info.num_audio_codecs-1) fputs(", ", fp); + } + fputc('\n', fp); + + fprintf(fp, " Audio extension(s): "); + for (i = 0;i < pmp->info.num_audio_extensions;++i) { + fprints(fp, "%s", pmp->info.audio_extensions[i]); + if (i != pmp->info.num_audio_extensions-1) fputs(";", fp); + } + fputc('\n', fp); + fprints(fp, " Root directory: %s\n", pmp->info.path_to_root); device_show_path(fp, " Music directory: %s\n", pmp->info.path_to_music); device_show_path(fp, " Playlist directory: %s\n", pmp->info.path_to_playlist); Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 15:39:06 UTC (rev 287) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-01-26 15:59:23 UTC (rev 288) @@ -94,7 +94,7 @@ case EASYPMPP_START: break; case EASYPMPP_OPEN|EASYPMPSP_START: - fprintf(fpo, "Opening the device\n"); + fprintf(fpo, "Opening the portable media device\n"); break; case EASYPMPP_OPEN|EASYPMPSP_END: fprintf(fpo, "\n"); @@ -117,7 +117,6 @@ case EASYPMPP_MUSIC_GMI|EASYPMPSP_END: console_clearln(fpo); fprintf(fpo, " %d files were imported\n", param_int); - fprintf(fpo, "\n"); break; case EASYPMPP_MUSIC_UPDATE|EASYPMPSP_START: fprintf(fpo, "Updating database entries\n"); @@ -361,7 +360,7 @@ fprintf(fpe, "Enumerating playlist files\n"); easypmp_enumerate_playlist(&playlists, pmp, &opt, easypmp_enumerate_progress, NULL); console_clearln(fpo); - fprintf(fpo, " %d music files were found\n", playlists.num_elements); + fprintf(fpo, " %d playlist files were found\n", playlists.num_elements); fprintf(fpo, "\n"); } 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-26 13:27:26
|
Revision: 286 http://svn.sourceforge.net/pmplib/?rev=286&view=rev Author: nyaochi Date: 2007-01-26 05:27:21 -0800 (Fri, 26 Jan 2007) Log Message: ----------- [pmp_iriverplus3] Fixed three bugs in db.idx generation: - If two strings are identical by comparing without case, compare the strings again with case. - Avoid the region for a page header because avl_rewind() may move the offset to a start position of a page. - Do not dump an index whose root offset is 0, which means an empty member of the index. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/idx.c Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 10:09:27 UTC (rev 285) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 13:27:21 UTC (rev 286) @@ -116,10 +116,16 @@ memset(avl->buffer + avl->size, 0, PAGESIZE); avl->offset = avl->size + sizeof(header_t); avl->size = newsize; - } else if (((avl->offset + size) / PAGESIZE) != (avl->offset / PAGESIZE)) { + } else { + int forward = 0; /* Avoid crossing a page boundary. */ - uint32_t page = (avl->offset + size) / PAGESIZE; - avl->offset = PAGESIZE * page + sizeof(header_t); + forward |= (((avl->offset + size - 1) / PAGESIZE) != (avl->offset / PAGESIZE)); + /* Avoid the region for a page header (caused by a rewind operation near a page boundary). */ + forward |= (avl->offset % PAGESIZE < sizeof(header_t)); + if (forward) { + uint32_t page = (avl->offset + size) / PAGESIZE; + avl->offset = PAGESIZE * page + sizeof(header_t); + } } /* Allocate a memory block. */ @@ -338,7 +344,7 @@ return str; } -static int avl_comp_ucs2string(avl_t* avl, uint32_t _x, uint32_t _y) +static int avl_comp_ucs2string_nocase(avl_t* avl, uint32_t _x, uint32_t _y) { ucs2char_t a, b; const ucs2char_t* x = (const ucs2char_t*)(avl->buffer + _x); @@ -359,6 +365,34 @@ return COMP(a, b); } +static int avl_comp_ucs2string(avl_t* avl, uint32_t _x, uint32_t _y) +{ + /* Compare strings, ignoring case. */ + int ret = avl_comp_ucs2string_nocase(avl, _x, _y); + if (ret == 0) { + /* Compare strings with case. */ + ucs2char_t a, b; + const ucs2char_t* x = (const ucs2char_t*)(avl->buffer + _x); + const ucs2char_t* y = (const ucs2char_t*)(avl->buffer + _y); + + x = skip_prefix(x); + y = skip_prefix(y); + + do { + a = *x; + b = *y; + if (!*x || !*y) { + break; + } + x++; + y++; + } while (a == b); + return COMP(a, b); + } else { + return ret; + } +} + static int avl_insert_key(avl_t* avl, const ip3db_variant_t* key, int type, uint32_t* offset, uint32_t* root) { int ret = 0; @@ -774,7 +808,9 @@ fprintf(fpo, "["); dic_repr_index(dic, IP3DBIDX_MUSIC, i, fpo); fprintf(fpo, "]\n"); - avl_dump(idx->avl, idx_root, &dic->music, i, 0, fpo); + if (idx_root) { + avl_dump(idx->avl, idx_root, &dic->music, i, 0, fpo); + } } for (i = 0;i < dic->references.num_indices;++i) { uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_REFERENCES, i); @@ -790,7 +826,9 @@ fprintf(fpo, "["); dic_repr_index(dic, IP3DBIDX_OBJECTS, i, fpo); fprintf(fpo, "]\n"); - avl_dump(idx->avl, idx_root, &dic->objects, i, 0, fpo); + if (idx_root) { + avl_dump(idx->avl, idx_root, &dic->objects, i, 0, fpo); + } } fprintf(fpo, "\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 10:09:27
|
Revision: 285 http://svn.sourceforge.net/pmplib/?rev=285&view=rev Author: nyaochi Date: 2007-01-26 02:09:27 -0800 (Fri, 26 Jan 2007) Log Message: ----------- [pmp_iriverplus3] - Fixed a bug of database construction without a playlist. Modified Paths: -------------- trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/idx.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-26 07:57:06 UTC (rev 284) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-26 10:09:27 UTC (rev 285) @@ -65,11 +65,13 @@ void pmplib_records_finish(pmp_music_record_t* records, int num_records) { - int i; - for (i = 0;i < num_records;++i) { - pmplib_record_finish(&records[i]); + if (records) { + int i; + for (i = 0;i < num_records;++i) { + pmplib_record_finish(&records[i]); + } + ucs2free(records); } - ucs2free(records); } result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records) @@ -110,11 +112,13 @@ 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]); + if (playlists) { + int i; + for (i = 0;i < num_playlists;++i) { + pmplib_playlist_finish(&playlists[i]); + } + ucs2free(playlists); } - ucs2free(playlists); } void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists) Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-26 07:57:06 UTC (rev 284) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-01-26 10:09:27 UTC (rev 285) @@ -364,6 +364,7 @@ if (dat) { dat_list_init(&dat->objects); dat_list_init(&dat->musics); + dat_list_init(&dat->references); } return dat; } @@ -372,6 +373,7 @@ { dat_list_finish(&dat->objects); dat_list_finish(&dat->musics); + dat_list_finish(&dat->references); free(dat); } @@ -472,24 +474,30 @@ long buffer_size = 0; uint8_t* buffer = NULL; + /* Initialize the number of pages as zero. */ dic->header.num_dat_pages = 0; + dic->objects.dat_page = 0; + dic->music.dat_page = 0; + dic->references.dat_page = 0; memset(&ph, 0, sizeof(ph)); /* Write Objects page(s) */ - i = 0; - dic->objects.dat_page = page = (dic->header.num_dat_pages + 1); - while (page) { - buffer_size = PAGESIZE * page; - buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); - memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); + if (0 < dat->objects.num_entries) { + i = 0; + dic->objects.dat_page = page = (dic->header.num_dat_pages + 1); + while (page) { + buffer_size = PAGESIZE * page; + buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); - ph.next_page = page + 1; - dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1)); + ph.next_page = page + 1; + dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1)); - i += ph.num_entries; - dic->header.num_dat_pages += 1; - page = ph.next_page; + i += ph.num_entries; + dic->header.num_dat_pages += 1; + page = ph.next_page; + } } /* Clear filepath and filename */ @@ -501,40 +509,47 @@ } /* Write Music page(s) */ - i = 0; - dic->music.dat_page = page = (dic->header.num_dat_pages+1); - while (page) { - buffer_size = PAGESIZE * page; - buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); - memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); + if (0 < dat->musics.num_entries) { + i = 0; + dic->music.dat_page = page = (dic->header.num_dat_pages+1); + while (page) { + buffer_size = PAGESIZE * page; + buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); - ph.next_page = page + 1; - dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1)); + ph.next_page = page + 1; + dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1)); - i += ph.num_entries; - dic->header.num_dat_pages += 1; - page = ph.next_page; + i += ph.num_entries; + dic->header.num_dat_pages += 1; + page = ph.next_page; + } } /* Write References page(s) */ - i = 0; - dic->references.dat_page = page = (dic->header.num_dat_pages+1); - while (page) { - buffer_size = PAGESIZE * page; - buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); - memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); + if (0 < dat->references.num_entries) { + i = 0; + dic->references.dat_page = page = (dic->header.num_dat_pages+1); + while (page) { + buffer_size = PAGESIZE * page; + buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); - ph.next_page = page + 1; - dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1)); + ph.next_page = page + 1; + dat_list_write(&dat->references, i, &ph, buffer, PAGESIZE * (page - 1)); - i += ph.num_entries; - dic->header.num_dat_pages += 1; - page = ph.next_page; + i += ph.num_entries; + dic->header.num_dat_pages += 1; + page = ph.next_page; + } } - if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) { - free(buffer); - return 1; + /* Write out the pages to the file. */ + if (buffer && buffer_size > 0) { + if (fwrite(buffer, 1, buffer_size, fpo) != buffer_size) { + free(buffer); + return 1; + } } free(buffer); Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 07:57:06 UTC (rev 284) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-01-26 10:09:27 UTC (rev 285) @@ -736,15 +736,21 @@ /* 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); - to_be_avltree(idx->avl, idx_root, &dic->music, i, 0); + if (idx_root) { + to_be_avltree(idx->avl, idx_root, &dic->music, i, 0); + } } for (i = 0;i < dic->references.num_indices;++i) { uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_REFERENCES, i); - to_be_avltree(idx->avl, idx_root, &dic->references, i, 0); + if (idx_root) { + to_be_avltree(idx->avl, idx_root, &dic->references, i, 0); + } } for (i = 0;i < dic->objects.num_indices;++i) { uint32_t idx_root = dic_get_idxroot(dic, IP3DBIDX_OBJECTS, i); - to_be_avltree(idx->avl, idx_root, &dic->objects, i, 0); + if (idx_root) { + to_be_avltree(idx->avl, idx_root, &dic->objects, i, 0); + } } /* Read the whole data at a time. */ Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 07:57:06 UTC (rev 284) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 10:09:27 UTC (rev 285) @@ -201,7 +201,7 @@ { "samsung_yh925", "Samsung", "YH-925", 5, "UM", - "1.61", "1.61", + "1.58", "1.61", "SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR", ".mp3\0.wma\0", {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2007-01-26 07:57:08
|
Revision: 284 http://svn.sourceforge.net/pmplib/?rev=284&view=rev Author: nyaochi Date: 2007-01-25 23:57:06 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Removed unnecessary comments. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c Modified: trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-26 07:55:48 UTC (rev 283) +++ trunk/pmplib/lib/pmp_iriverplus2/pmp_iriverplus2.c 2007-01-26 07:57:06 UTC (rev 284) @@ -609,83 +609,3 @@ return 0; } - -/* -static result_t pmpdb_read(pmp_music_t* pmpdb) -{ - 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) -{ - 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) -{ - 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) -{ - 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) -{ - pmp_music_internal_t* pmpdbi = (pmp_music_internal_t*)pmpdb->instance; - if (level > 0) { - return ip2db_repr(&pmpdbi->ip2db, fp); - } else { - return ip2db_dump(&pmpdbi->ip2db, fp); - } -} - -static int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec) -{ - return ip2db_is_supported_codec(codec); -} - -static int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename) -{ - return ip2db_is_supported_ext(filename); -} - - - - - -static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) -{ - return pmplib_interlocked_increment(&pmppl->ref_count); -} - -static uint32_t pmppl_release(pmp_playlist_t* pmppl) -{ - uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); - if (count == 0) { - pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; - free(pmppl->instance); - free(pmppl); - } - return count; -} - -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) -{ - pmppl_internal_t* pmppli = (pmppl_internal_t*)pmppl->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; - if (ip2db_playlist_write(&pmppli->ip2db, filename, files, num_files, pmpi->env.path_to_root) != 0) { - return PMPPLE_WRITE; - } - return 0; -} -*/ \ No newline at end of file Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-26 07:55:48 UTC (rev 283) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-26 07:57:06 UTC (rev 284) @@ -607,14 +607,3 @@ return 0; } - -/* -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) -{ - pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; - if (playlist_write(filename, files, num_files, pmpi->env.path_to_root) != 0) { - return PMPPLE_WRITE; - } - 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-26 07:55:54
|
Revision: 283 http://svn.sourceforge.net/pmplib/?rev=283&view=rev Author: nyaochi Date: 2007-01-25 23:55:48 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Synchronize pmp_irivnavi with the latest API. Modified Paths: -------------- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-26 03:44:58 UTC (rev 282) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-01-26 07:55:48 UTC (rev 283) @@ -67,6 +67,10 @@ {'S','y','s','t','e','m',PATHCHAR,'H','1','0','0','.','s','y','s',0}; static const ucs2char_t ucs2cs_system_h300_sys[] = {'S','y','s','t','e','m',PATHCHAR,'H','3','0','0','.','s','y','s',0}; +static const uint32_t g_codecs[] = + {PMPCODEC_MPEGLAYER3, PMPCODEC_VORBIS, PMPCODEC_WMA, PMPCODEC_WAV}; +static const char *g_music_exts[] = + {".mp3", ".ogg", ".wma", ".wav"}; #define MODELID_H100 "iriver_h100" #define MODELID_H300 "iriver_h300" @@ -83,28 +87,28 @@ irivnavi_environment_t env; } pmp_internal_t; +typedef struct { + irivnavi_t db; + pmp_music_record_t* records; + int num_records; + pmp_playlist_t* playlists; + int num_playlists; +} pmp_music_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_add_ref(pmp_music_t* 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 result_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); - static int exists_sysfile(const ucs2char_t* path_to_device, const ucs2char_t* sysfilename) { ucs2char_t filename[MAX_PATH]; @@ -115,6 +119,17 @@ return filepath_file_exists(filename); } +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)); +} + PMPIRIVNAVIAPI result_t pmp_enumerate_devid(pmplib_enumerate_devid_callback_t callback, void *instance) { callback(instance, MODELID_H100); @@ -126,9 +141,11 @@ { int model = MODEL_NONE; result_t ret = 0; + size_t i = 0, n = 0; pmp_t* pmp = NULL; pmp_internal_t* pmpi = NULL; - pmp_device_environment_t* pmpenv = NULL; + pmp_device_information_t* info = NULL; + pmp_device_description_t* decl = NULL; *ptr_pmp = 0; @@ -173,7 +190,6 @@ 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. @@ -185,46 +201,49 @@ pmp->instance = pmpi; // Initialize the internal variables. - ucs2cpy(pmpi->env.path_to_root, path_to_device); - ucs2cpy(pmpi->env.path_to_music, path_to_device); // Force "\Music" directory for now. - filepath_addslash(pmpi->env.path_to_music); - ucs2cat(pmpi->env.path_to_music, ucs2cs_music_path); - ucs2cpy(pmpi->env.path_to_playlist, path_to_device); // Force "\Playlist" directory for now. - filepath_addslash(pmpi->env.path_to_playlist); - ucs2cat(pmpi->env.path_to_playlist, ucs2cs_playlist_path); - ucs2cpy(pmpi->env.playlist_ext, ucs2cs_playlist_ext); + info = &pmp->info; + decl = (pmp_device_description_t*)&info->decl; + ucs2cpy(info->path_to_root, path_to_device); + ucs2cpy(info->path_to_music, ucs2cs_music_path); // Force "\Music" directory for now. + ucs2cpy(info->path_to_playlist, ucs2cs_playlist_path); // Force "\Playlist" directory for now. + // Set model information. switch (model) { case MODEL_IRIVER_H100: - strcpy(pmp->decl.id, MODELID_H100); - strcpy(pmp->decl.manufacturer, "iriver"); - strcpy(pmp->decl.name, "H100 series"); + strcpy(decl->id, MODELID_H100); + strcpy(decl->manufacturer, "iriver"); + strcpy(decl->name, "H100 series"); break; case MODEL_IRIVER_H300: - strcpy(pmp->decl.id, MODELID_H300); - strcpy(pmp->decl.manufacturer, "iriver"); - strcpy(pmp->decl.name, "H300 series"); + strcpy(decl->id, MODELID_H300); + strcpy(decl->manufacturer, "iriver"); + strcpy(decl->name, "H300 series"); break; } - strcpy(pmp->decl.mode, "UM"); - strcpy(pmp->decl.language, PMP_DECLUNAVAIL); - strcpy(pmp->decl.version, PMP_DECLUNAVAIL); - strcpy(pmp->decl.max_version, PMP_DECLUNAVAIL); - strcpy(pmp->decl.min_version, PMP_DECLUNAVAIL); + strcpy(decl->mode, "UM"); + strcpy(decl->language, PMP_DECLUNAVAIL); + strcpy(decl->version, PMP_DECLUNAVAIL); + strcpy(decl->max_version, PMP_DECLUNAVAIL); + strcpy(decl->min_version, PMP_DECLUNAVAIL); - // Set enviroments. - 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 | PMPPEF_RECURSIVE; - ucs2cpy(pmpenv->path_to_playlist.path, pmpi->env.path_to_playlist); - ucs2cpy(pmpenv->playlist_ext, pmpi->env.playlist_ext); + info->music_flag = PMPMF_SUPPORT | PMPMF_RECURSIVE; + info->playlist_flag = PMPPF_SUPPORT; + // Audio codecs. + info->num_audio_codecs = sizeof(g_codecs) / sizeof(g_codecs[0]); + info->audio_codecs = (uint32_t*)ucs2malloc(sizeof(uint32_t) * info->num_audio_codecs); + memcpy(info->audio_codecs, g_codecs, sizeof(g_codecs)); + + // Obtain the number of extensions separated by '\0' characters. + info->num_audio_extensions = sizeof(g_music_exts) / sizeof(g_music_exts[0]); + info->audio_extensions = (ucs2char_t**)ucs2malloc(sizeof(ucs2char_t*) * info->num_audio_extensions); + for (i = 0;i < info->num_audio_extensions;++i) { + info->audio_extensions[i] = mbsdupucs2(g_music_exts[i]); + } + // 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; @@ -244,7 +263,9 @@ { 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); } return count; @@ -253,192 +274,170 @@ 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; - } - } - return 0; -} -static result_t pmp_create_instance_db(pmp_t* pmp, pmp_music_t** ptr_pmpdb) -{ - pmp_music_t* pmpdb = NULL; - irivnavi_t* irivnavi = NULL; - - *ptr_pmpdb = 0; - - // Allocate a PMPDB instance. - pmpdb = (pmp_music_t*)calloc(1, sizeof(pmp_music_t)); - if (!pmpdb) { - return PMPDBE_OUTOFMEMORY; + // Close the music database. + ret = pmpmusic_close(pmp->music); + if (ret) { + return ret; } - // Set member methods. - 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; - - // Allocate and initialize an internal object (irivnavi_t). - irivnavi = (irivnavi_t*)calloc(1, sizeof(irivnavi_t)); - if (!irivnavi) { - free(pmpdb); - return PMPDBE_OUTOFMEMORY; - } - irivnavi_init(irivnavi); - - // Set member variables. - pmpdb->pmp = pmp; - pmpdb->instance = irivnavi; - - *ptr_pmpdb = pmpdb; return 0; } -result_t pmp_create_instance_pl(pmp_t* pmp, pmp_playlist_t** ptr_pmppl) +static result_t pmp_create_instance_music(pmp_t* pmp, pmp_music_t** ptr_music) { + pmp_music_t* music = NULL; pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmp_playlist_t* pmppl = NULL; + pmp_music_internal_t* pmpmi = NULL; - *ptr_pmppl = 0; + *ptr_music = 0; - pmppl = (pmp_playlist_t*)calloc(1, sizeof(pmp_playlist_t)); - if (!pmppl) { + music = calloc(1, sizeof(pmp_music_t)); + if (!music) { return PMPDBE_OUTOFMEMORY; } - pmppl->add_ref = pmppl_add_ref; - pmppl->release = pmppl_release; - pmppl->write = pmppl_write; + pmpmi = calloc(1, sizeof(pmp_music_internal_t)); + if (!pmpmi) { + free(music); + return PMPDBE_OUTOFMEMORY; + } + irivnavi_init(&pmpmi->db); - pmppl->pmp = pmp; + 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; - pmppl->add_ref(pmppl); - *ptr_pmppl = pmppl; + *ptr_music = music; return 0; } -static uint32_t pmpdb_release(pmp_music_t* pmpdb) +static uint32_t pmpmusic_release(pmp_music_t* music) { - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; - if (db) { - irivnavi_finish(db); - free(db); - } - free(pmpdb); + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + irivnavi_finish(&pmpmi->db); + pmplib_records_finish(pmpmi->records, pmpmi->num_records); + free(pmpmi->playlists); + free(pmpmi); + free(music); return 0; } -result_t pmpdb_read(pmp_music_t* pmpdb) +uint32_t pmpmusic_open(pmp_music_t* music) { - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; result_t ret = 0; FILE *fp = NULL; ucs2char_t filename[MAX_PATH]; long size = 0; + int i, j; uint8_t *buffer = NULL; + static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; + static const ucs2char_t ucs2cs_ogg[] = {'.','o','g','g',0}; + static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; + static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; - // Open a database file in the root directory. - ucs2cpy(filename, pmpdb->pmp->env.path_to_root.path); - filepath_addslash(filename); - ucs2cat(filename, ucs2cs_irivnavi_idb); - fp = ucs2fopen(filename, "rb"); - if (!fp) { - return PMPDBE_OPENFORREAD; - } + if (music->pmp->flag & PMPOF_MUSIC_DB_READ) { + // Open a database file in the root directory. + ucs2cpy(filename, music->pmp->info.path_to_root); + filepath_addslash(filename); + ucs2cat(filename, ucs2cs_irivnavi_idb); + fp = ucs2fopen(filename, "rb"); + if (!fp) { + return PMPDBE_OPENFORREAD; + } - // Obtain the stream size. - if (fseek(fp, 0, SEEK_END) != 0) { - return PMPDBE_OPENFORREAD; - } - if ((size = ftell(fp)) == -1) { - return PMPDBE_OPENFORREAD; - } - if (fseek(fp, 0, SEEK_SET) != 0) { - return PMPDBE_OPENFORREAD; - } + // Obtain the stream size. + if (fseek(fp, 0, SEEK_END) != 0) { + return PMPDBE_OPENFORREAD; + } + if ((size = ftell(fp)) == -1) { + return PMPDBE_OPENFORREAD; + } + if (fseek(fp, 0, SEEK_SET) != 0) { + return PMPDBE_OPENFORREAD; + } - // Allocate a buffer that stores the whole data. - buffer = (uint8_t*)malloc(size); - if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; - goto error_exit; - } + // Allocate a buffer that stores the whole data. + buffer = (uint8_t*)malloc(size); + if (!buffer) { + ret = PMPDBE_OUTOFMEMORY; + goto error_exit; + } - // Read at one time. - fread(buffer, 1, size, fp); + // Read at one time. + fread(buffer, 1, size, fp); - // Read the data from the buffer. - if (irivnavi_serialize(db, buffer, 0) == 0) { - ret = PMPDBE_DBINCONSIST; - goto error_exit; - } + // Read the data from the buffer. + if (irivnavi_serialize(&pmpmi->db, buffer, 0) == 0) { + ret = PMPDBE_DBINCONSIST; + goto error_exit; + } - free(buffer); - fclose(fp); - return 0; + // Free the buffer and file. + free(buffer); + fclose(fp); -error_exit: - free(buffer); - if (fp) fclose(fp); - return ret; -} + // + pmpmi->num_records = pmpmi->db.num_records; + pmpmi->records = (pmp_music_record_t*)ucs2malloc(sizeof(pmp_music_record_t) * pmpmi->num_records); -result_t pmpdb_write(pmp_music_t* pmpdb) -{ - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; - result_t ret = 0; - FILE *fp = NULL; - ucs2char_t filename[MAX_PATH]; - uint8_t *buffer = NULL; + for (i = 0, j = 0;i < pmpmi->num_records;++i) { + size_t length = 0; + ucs2char_t* tmp = NULL; + const record_t* src = &pmpmi->db.records[i]; + pmp_music_record_t* dst = &pmpmi->records[j]; - // Open a database file in the root directory. - ucs2cpy(filename, pmpdb->pmp->env.path_to_root.path); - filepath_addslash(filename); - ucs2cat(filename, ucs2cs_irivnavi_idb); - filepath_removefile(filename); - fp = ucs2fopen(filename, "wb"); - if (!fp) { - return PMPDBE_OPENFORREAD; - } + pmplib_record_init(dst); - irivnavi_update(db); + tmp = mbsdupucs2(src->filename); + length = ucs2len(music->pmp->info.path_to_root); + length += ucs2len(tmp); + length += 3; - // Allocate a buffer that stores the whole data. - buffer = (uint8_t*)malloc(db->size); - if (!buffer) { - ret = PMPDBE_OUTOFMEMORY; - goto error_exit; - } + dst->filename = ucs2malloc(sizeof(ucs2char_t) * length); + filepath_combinepath(dst->filename, length, music->pmp->info.path_to_root, tmp); + dst->title = mbsdupucs2(src->title); + dst->artist = mbsdupucs2(src->artist); + dst->album = mbsdupucs2(src->album); + dst->genre = mbsdupucs2(src->genre); - // Write the data to the buffer. - if (irivnavi_serialize(db, buffer, 1) == 0) { - ret = PMPDBE_DBINCONSIST; - goto error_exit; - } + // Set codec information according to the file extensions. + if (filepath_hasext(dst->filename, ucs2cs_mp3)) { + dst->codec = PMPCODEC_MPEGLAYER3; + } else if (filepath_hasext(dst->filename, ucs2cs_ogg)) { + dst->codec = PMPCODEC_VORBIS; + } else if (filepath_hasext(dst->filename, ucs2cs_wma)) { + dst->codec = PMPCODEC_WMA; + } else if (filepath_hasext(dst->filename, ucs2cs_wav)) { + dst->codec = PMPCODEC_WAV; + } - // Write at one time. - fwrite(buffer, 1, db->size, fp); + dst->ts_update = src->timestamp; - free(buffer); - fclose(fp); + ucs2free(tmp); + ++j; + } + } return 0; error_exit: @@ -447,171 +446,169 @@ return ret; } -result_t pmpdb_set(pmp_music_t* pmpdb, const pmp_music_record_t* records, uint32_t num_records) +result_t pmpmusic_close(pmp_music_t* music) { - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; + int i, j; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; result_t ret = 0; - uint32_t i, j, n = 0; + FILE *fp = NULL; + ucs2char_t filename[MAX_PATH]; + uint8_t *buffer = NULL; static const ucs2char_t ucs2cs_unknown[] = {'u','n','k','n','o','w','n',0}; - const ucs2char_t* path_to_root = pmpdb->pmp->env.path_to_root.path; + static const ucs2char_t m3u_ext[] = {'.','m','3','u',0}; - // Clear the database. - irivnavi_finish(db); - irivnavi_init(db); + if (music->pmp->flag & PMPOF_MUSIC_DB_WRITE) { + // Clear the database. + irivnavi_finish(&pmpmi->db); + irivnavi_init(&pmpmi->db); - // Count the number of valid entries. - n = 0; - for (i = 0;i < num_records;++i) { - if (pmpdb_is_supported_codec(pmpdb, records[i].codec)) { - ++n; + // Initialize the record array. + if (irivnavi_init_records(&pmpmi->db, pmpmi->num_records) != 0) { + return PMPDBE_OUTOFMEMORY; } - } + + // Convert records from pmp_music_record_t to ip2db_record_t. + for (i = 0, j = 0;i < pmpmi->num_records;++i) { + const pmp_music_record_t* src = &pmpmi->records[i]; + record_t* dst = &pmpmi->db.records[j]; - // Initialize the record array. - if (irivnavi_init_records(db, n) != 0) { - return PMPDBE_OUTOFMEMORY; - } - - // Convert records from pmp_music_record_t to ip2db_record_t. - for (i = 0, j = 0;i < num_records;++i) { - const pmp_music_record_t* src = &records[i]; - record_t* dst = &db->records[j]; + // Set record fields. + record_init(dst); + dst->filename = ucs2dupmbs(filepath_skipdrive(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); + dst->genre = ucs2dupmbs(src->genre ? src->genre : ucs2cs_unknown); + dst->timestamp = src->ts_update; - // Skip unsupported codec. - if (!pmpdb_is_supported_codec(pmpdb, src->codec)) { - continue; + ++j; } - // Set record fields. - record_init(dst); - dst->filename = ucs2dupmbs(filepath_skipdrive(src->filename, 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); - dst->genre = ucs2dupmbs(src->genre ? src->genre : ucs2cs_unknown); - dst->timestamp = src->ts_update; + pmpmi->db.num_records = pmpmi->num_records; - ++j; - } + // Open a database file in the root directory. + ucs2cpy(filename, music->pmp->info.path_to_root); + filepath_addslash(filename); + ucs2cat(filename, ucs2cs_irivnavi_idb); + filepath_removefile(filename); + fp = ucs2fopen(filename, "wb"); + if (!fp) { + return PMPDBE_OPENFORREAD; + } - db->num_records = n; + irivnavi_update(&pmpmi->db); - return 0; -} + // Allocate a buffer that stores the whole data. + buffer = (uint8_t*)malloc(pmpmi->db.size); + if (!buffer) { + ret = PMPDBE_OUTOFMEMORY; + goto error_exit; + } -static result_t pmpdb_get(pmp_music_t* pmpdb, pmp_music_record_t* records, uint32_t* num_records) -{ - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; - result_t ret = 0; - uint32_t i, j, n = db->num_records; - const ucs2char_t* path_to_root = pmpdb->pmp->env.path_to_root.path; - static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; - static const ucs2char_t ucs2cs_ogg[] = {'.','o','g','g',0}; - static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; - static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; + // Write the data to the buffer. + if (irivnavi_serialize(&pmpmi->db, buffer, 1) == 0) { + ret = PMPDBE_DBINCONSIST; + goto error_exit; + } - if (!records) { - *num_records = n; - return 0; - } + // Write at one time. + fwrite(buffer, 1, pmpmi->db.size, fp); - if (*num_records < n) { - *num_records = n; - return PMPDBE_INSUFFICIENT; + free(buffer); + fclose(fp); } - for (i = 0, j = 0;i < n;++i) { - size_t length = 0; - ucs2char_t* tmp = NULL; - const record_t* src = &db->records[i]; - pmp_music_record_t* dst = &records[j]; + if (music->pmp->flag & PMPOF_MUSIC_PL_WRITE) { + int i; - pmplib_record_init(dst); + for (i = 0;i < pmpmi->num_playlists;++i) { + const ucs2char_t* path_to_root = music->pmp->info.path_to_root; + const ucs2char_t* path_to_playlist = music->pmp->info.path_to_playlist; + const pmp_playlist_t* pl = &pmpmi->playlists[i]; + ucs2char_t dst[MAX_PATH]; - tmp = mbsdupucs2(src->filename); - length = ucs2len(path_to_root); - length += ucs2len(tmp); - length += 3; + filepath_combinepath(dst, MAX_PATH, path_to_root, path_to_playlist); + filepath_addslash(dst); + ucs2cat(dst, pl->name); + ucs2cat(dst, m3u_ext); - dst->filename = ucs2malloc(sizeof(ucs2char_t) * length); - filepath_combinepath(dst->filename, length, path_to_root, tmp); - dst->title = mbsdupucs2(src->title); - dst->artist = mbsdupucs2(src->artist); - dst->album = mbsdupucs2(src->album); - dst->genre = mbsdupucs2(src->genre); - // Set codec information according to the file extensions. - if (filepath_hasext(dst->filename, ucs2cs_mp3)) { - dst->codec = PMPCODEC_MPEGLAYER3; - } else if (filepath_hasext(dst->filename, ucs2cs_ogg)) { - dst->codec = PMPCODEC_VORBIS; - } else if (filepath_hasext(dst->filename, ucs2cs_wma)) { - dst->codec = PMPCODEC_WMA; - } else if (filepath_hasext(dst->filename, ucs2cs_wav)) { - dst->codec = PMPCODEC_WAV; + if (playlist_write( + dst, + pl->entries, + pl->num_entries, + path_to_root + ) != 0) { + return PMPPLE_WRITE; + } } - - dst->ts_update = src->timestamp; - - ucs2free(tmp); - ++j; } return 0; + +error_exit: + free(buffer); + if (fp) fclose(fp); + 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); -result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level) -{ - irivnavi_t* db = (irivnavi_t*)pmpdb->instance; - irivnavi_repr(db, fp, level); + /* 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 int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec) +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records) { - return ( - (codec == PMPCODEC_MPEGLAYER3) || - (codec == PMPCODEC_VORBIS) || - (codec == PMPCODEC_WMA) || - (codec == PMPCODEC_WAV) - ) ? 1 : 0; + 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 int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename) +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) { - static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; - static const ucs2char_t ucs2cs_ogg[] = {'.','o','g','g',0}; - static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; - static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; - - return ( - filepath_hasext(filename, ucs2cs_mp3) || - filepath_hasext(filename, ucs2cs_ogg) || - filepath_hasext(filename, ucs2cs_wma) || - filepath_hasext(filename, ucs2cs_wav) - ) ? 1 : 0; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + irivnavi_repr(&pmpmi->db, fp, level); + return 0; } +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 pmppl_add_ref(pmp_playlist_t* pmppl) -{ - return pmplib_interlocked_increment(&pmppl->ref_count); + return 0; } -static uint32_t pmppl_release(pmp_playlist_t* pmppl) -{ - uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); - if (count == 0) { - free(pmppl); - } - return count; -} - +/* static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) { pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; @@ -620,3 +617,4 @@ } 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-26 03:44:58
|
Revision: 282 http://svn.sourceforge.net/pmplib/?rev=282&view=rev Author: nyaochi Date: 2007-01-25 19:44:58 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Synchronize pmp_portalplayer1 with the latest API. Modified Paths: -------------- trunk/pmplib/lib/pmp/pmp.c trunk/pmplib/lib/pmp_portalplayer1/playlist.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj trunk/pmplib/lib/pmp_portalplayer1/pp1db.h Modified: trunk/pmplib/lib/pmp/pmp.c =================================================================== --- trunk/pmplib/lib/pmp/pmp.c 2007-01-26 02:36:01 UTC (rev 281) +++ trunk/pmplib/lib/pmp/pmp.c 2007-01-26 03:44:58 UTC (rev 282) @@ -78,6 +78,7 @@ for (i = 0;i < num_records;++i) { pmplib_record_clone(&dst[i], &src[i]); } + return 0; } void pmplib_playlist_init(pmp_playlist_t* playlist) Modified: trunk/pmplib/lib/pmp_portalplayer1/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/playlist.c 2007-01-26 02:36:01 UTC (rev 281) +++ trunk/pmplib/lib/pmp_portalplayer1/playlist.c 2007-01-26 03:44:58 UTC (rev 282) @@ -50,19 +50,29 @@ return count; } -int playlist_write( - const ucs2char_t *filename, +int pp1db_playlist_write( + pp1db_t* db, + 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 ) { + FILE *fp = NULL; static const ucs2char_t header1_str[] = {'P','L','P',' ','P','L','A','Y','L','I','S','T','\r','\n', 0}; static const ucs2char_t header2_str[] = {'V','E','R','S','I','O','N',' ','1','.','2','0','\r','\n', 0}; static const ucs2char_t entry_str[] = {'H','D','D',',',' ', 0}; static const ucs2char_t crlf_str[] = {'\r','\n', 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); - FILE *fp = ucs2fopen(filename, "wb"); + fp = ucs2fopen(dst, "wb"); if (!fp) { return -1; } else { Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 02:36:01 UTC (rev 281) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.c 2007-01-26 03:44:58 UTC (rev 282) @@ -55,6 +55,9 @@ const char *max_version; const char *fw_filename; const char *hdr_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; @@ -67,7 +70,10 @@ "iriver_h10_5/6gb_ums_2.04-2.53", "iriver", "H10 5GB/6GB UMS", 5, "UM", "2.04", "2.53", - "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", + "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\\", ".plp", hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, @@ -75,7 +81,10 @@ "iriver_h10pure_5/6gb_ums_2.04-2.51", "iriver", "H10Pure 5GB/6GB UMS", 5, "UM", "2.04", "2.51", - "System\\H10_5GP.mi4", "System\\DATA\\H10DB.hdr", "Media\\Music\\", "Media\\Playlist\\", + "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\\", ".plp", hdr_init_h10_5gb_ums_0205_0253, iriver_h10_parse_model }, @@ -83,7 +92,10 @@ "iriver_h10_5/6gb_mtp_2.03-2.10", "iriver", "H10 5GB/6GB MTP", 5, "MT", "2.03", "2.10", - "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, @@ -91,7 +103,10 @@ "iriver_h10pure_5/6gb_mtp_2.03-2.10", "iriver", "H10Pure 5GB/6GB MTP", 5, "MT", "2.03", "2.10", - "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_5gb_mtp_0203_0210, iriver_h10_parse_model }, @@ -99,7 +114,10 @@ "iriver_h10_5/6gb_mtp_2.51", "iriver", "H10 5GB/6GB MTP", 5, "MT", "2.51", "2.51", - "System\\H10.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, @@ -107,7 +125,10 @@ "iriver_h10pure_5/6gb_mtp_2.51", "iriver", "H10Pure 5GB/6GB MTP", 5, "MT", "2.51", "2.51", - "System\\H10EMP.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_5gb_mtp_0251, iriver_h10_parse_model }, @@ -115,7 +136,10 @@ "iriver_h10_20gb_mtp_1.00-1.02", "iriver", "H10 20GB MTP", 20, "MT", "1.00", "1.02", - "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_20gb_mtp_0100_0102, iriver_h10_parse_model }, @@ -123,7 +147,10 @@ "iriver_h10_20gb_mtp_2.51", "iriver", "H10 20GB MTP", 20, "MT", "2.51", "2.51", - "System\\H10_20GC.mi4", "System\\DATA\\H10DB.hdr", "Music\\", "Playlists\\", + "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\\", ".pla", hdr_init_h10_20gb_mtp_0251, iriver_h10_parse_model }, @@ -131,7 +158,10 @@ "medion_mdjuke220", "MEDION", "MDJUKE220", 20, "UM", "1.4.2", "1.4.2", - "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", + "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", + ".mp3\0.wma\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, + "SYSTEM\\", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", ".pla", hdr_init_medion_mdjuke220, medion_mdjuke220_parse_model }, @@ -139,7 +169,10 @@ "medion_mdjuke440", "MEDION", "MDJUKE440", 20, "UM", "1.5.5", "1.5.5", - "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", + "SYSTEM\\JUKEBOX.mi4", "SYSTEM\\DATA\\PP5000.HDR", + ".mp3\0.wma\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, + "SYSTEM\\", "MyJukeBox\\MUSIC\\", "MyJukeBox\\Playlist\\", ".pla", hdr_init_medion_mdjuke440, medion_mdjuke220_parse_model }, @@ -147,7 +180,10 @@ "samsung_yh820", "Samsung", "YH-820", 5, "UM", "3.00", "3.00", - "SYSTEM\\FW_YH820.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", + "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\\", ".plp", hdr_init_samsung_yh820, samsung_parse_model }, @@ -155,7 +191,10 @@ "samsung_yh920", "Samsung", "YH-920", 20, "UM", "5.15", "5.15", - "SYSTEM\\FW_YH920.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", + "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\\", ".plp", hdr_init_samsung_yh920, samsung_parse_model }, @@ -163,7 +202,10 @@ "samsung_yh925", "Samsung", "YH-925", 5, "UM", "1.61", "1.61", - "SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", + "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\\", ".plp", hdr_init_samsung_yh925, samsung_parse_model }, @@ -171,7 +213,10 @@ "philips_hdd6320", "Philips", "HDD6320", 20, "UM", "5.40", "5.40", - "SYSTEM\\FWImage.ebn", "System\\DATA\\PP5000.HDR", "Music\\", "Playlists\\", + "SYSTEM\\FWImage.ebn", "System\\DATA\\PP5000.HDR", + ".mp3\0.wma\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, + "SYSTEM\\", "Music\\", "Playlists\\", ".pla", hdr_init_philips_hdd6320, philips_hdd6320_parse_model }, @@ -179,7 +224,10 @@ "msi_megaplayer540", "MSI", "MEGA PLAYER 540", 8, "UM", "01.00.16", "01.00.16", - "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", "MUSIC\\", "Playlists\\", + "SYSTEM\\PP5020.mi4", "System\\DATA\\PP5000.HDR", + ".mp3\0.wma\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, + "SYSTEM\\", "MUSIC\\", "Playlists\\", ".pla", hdr_init_msi_megaplayer540, megaplayer_parse_model }, @@ -188,7 +236,10 @@ "sirius_s50", "Sirius", "S50", 1, "UM", "0.00", "0.00", - "SYSTEM\\config\\sysinfo.cfg", "SYSTEM\\DB\\SONG\\Xena.HDR", "SYSTEM\\MEDIA\\MP3\\", "SYSTEM\\MEDIA\\PLAYLIST\\", + "SYSTEM\\config\\sysinfo.cfg", "SYSTEM\\DB\\SONG\\Xena.HDR", + ".mp3\0.wma\0", + {PMPCODEC_MPEGLAYER3, PMPCODEC_WMA, 0, 0, 0, 0}, + "SYSTEM\\", "SYSTEM\\MEDIA\\MP3\\", "SYSTEM\\MEDIA\\PLAYLIST\\", ".pla", hdr_init_sirius_s50, iriver_h10_parse_model }, @@ -197,146 +248,196 @@ NULL, NULL, NULL, 0, NULL, 0, 0, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, + {0, 0, 0, 0, 0, 0, 0, 0}, + NULL, NULL, NULL, + NULL, NULL, NULL }, }; typedef struct { - pp1model_t model; - ucs2char_t path_to_root[MAX_PATH]; - ucs2char_t path_to_music[MAX_PATH]; - ucs2char_t path_to_playlist[MAX_PATH]; - ucs2char_t fw_filename[MAX_PATH]; - ucs2char_t hdr_filename[MAX_PATH]; - ucs2char_t playlist_ext[MAX_PATH]; - hdr_init_t hdr_initproc; -} pp1_environment_t; - - -typedef struct { - pp1_environment_t env; + const pp1model_descriptor_t* decl; } pmp_internal_t; typedef struct { pp1db_t pp1db; -} pmpdb_internal_t; + pmp_music_record_t* records; + int num_records; + pmp_playlist_t* playlists; + int num_playlists; +} pmp_music_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 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_environment( - pp1_environment_t* env, +static void set_filenames(ucs2char_t *hdr, pmp_t *pmp) +{ + ucs2char_t* ucs2 = NULL; + pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; + + ucs2cpy(hdr, pmp->info.path_to_root); + filepath_addslash(hdr); + ucs2 = mbsdupucs2(pmpi->decl->hdr_filename); + ucs2cat(hdr, ucs2); + ucs2free(ucs2); +} + +static void set_device_info( + const char *id, + const ucs2char_t* path_to_device, const pp1model_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->fw_filename, path_to_device); - filepath_addslash(env->fw_filename); - ucs2 = mbsdupucs2(md->fw_filename); - ucs2cat(env->fw_filename, ucs2); - ucs2free(ucs2); + 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->min_version, md->min_version); + strcpy_if_empty(decl->max_version, md->max_version); - ucs2cpy(env->hdr_filename, path_to_device); - filepath_addslash(env->hdr_filename); - ucs2 = mbsdupucs2(md->hdr_filename); - ucs2cat(env->hdr_filename, ucs2); + ucs2cpy(info->path_to_root, path_to_device); + + ucs2 = mbsdupucs2(md->path_to_system); + ucs2cpy(info->path_to_system, ucs2); ucs2free(ucs2); - ucs2cpy(env->path_to_root, path_to_device); - - ucs2cpy(env->path_to_music, path_to_device); - filepath_addslash(env->path_to_music); 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); - ucs2 = mbsdupucs2(md->playlist_ext); - ucs2cpy(env->playlist_ext, ucs2); - ucs2free(ucs2); + info->music_flag = PMPMF_SUPPORT | PMPMF_RECURSIVE; + info->playlist_flag = PMPPF_SUPPORT; - env->hdr_initproc = md->hdr_initproc; + // 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]; + } + + // 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); + } } -static int match_model( - const char *id, - const ucs2char_t* path_to_device, - const pp1model_descriptor_t* md, - pp1_environment_t* env - ) +static void free_device_info(pmp_device_information_t* info) { - memset(env, 0, sizeof(pp1_environment_t)); + 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)); +} - if (!id || strcmp(md->id, id) != 0) { - return 0; +static int compare_version(const char *x, const char *y) +{ + char *p = NULL, *q = NULL; + + for (;;) { + long a = strtol(x, &p, 10); + long b = strtol(y, &q, 10); + int value = COMP(a, b); + if (value != 0) { + return value; + } + if (!*p || !*q || *p != *q) { + return COMP(*p, *q); + } + x = p+1; + y = q+1; } - - set_environment(env, md, path_to_device); - return 1; } - static int detect_model( const ucs2char_t* path_to_device, const pp1model_descriptor_t* md, - pp1_environment_t* env + pmp_device_information_t* ptr_info ) { ucs2char_t* ucs2 = NULL; ucs2char_t filename[MAX_PATH]; + pp1model_t model; + pmp_device_description_t decl; - memset(env, 0, sizeof(pp1_environment_t)); + memset(&model, 0, sizeof(model)); + memset(&decl, 0, sizeof(decl)); - // Check the existence of a firmware file. + // filename = "${path_to_device}/${md->sys_filename}" ucs2cpy(filename, path_to_device); filepath_addslash(filename); ucs2 = mbsdupucs2(md->fw_filename); ucs2cat(filename, ucs2); ucs2free(ucs2); + if (filepath_file_exists(filename)) { // Check the product identifier and firmware version. - if (md->parse_model_proc(filename, &env->model)) { - if (compare_version(env->model.version, md->min_version) < 0) { - return 0; + if (md->parse_model_proc(filename, &model)) { + int match = 1; + strcpy(decl.name, model.name); + strcpy(decl.mode, model.mode); + strcpy(decl.language, model.language); + strcpy(decl.version, model.version); + + 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) { + memcpy((pmp_device_description_t*)&ptr_info->decl, &decl, sizeof(decl)); + return 1; } - if (compare_version(md->max_version, env->model.version) < 0) { - return 0; - } - if (strcmp(env->model.mode, md->mode) != 0) { - return 0; - } - - set_environment(env, md, path_to_device); - return 1; } } return 0; @@ -360,26 +461,32 @@ pmp_t* pmp = NULL; pmp_internal_t* pmpi = NULL; const pp1model_descriptor_t* md = NULL; - pp1_environment_t env; - pmp_device_environment_t* pmpenv = NULL; + pmp_device_information_t info; - // Initialize. + // 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; @@ -391,10 +498,8 @@ return PMPDBE_OUTOFMEMORY; } - // Set methods. pmp->add_ref = pmp_add_ref; pmp->release = pmp_release; - pmp->create_instance_pl = pmp_create_instance_pl; pmp->open = pmp_open; pmp->close = pmp_close; pmp->add_ref(pmp); @@ -402,36 +507,17 @@ // 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 device description. - 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.model.language); - strcpy(pmp->decl.version, pmpi->env.model.version); - strcpy(pmp->decl.min_version, md->min_version); - strcpy(pmp->decl.max_version, md->max_version); - - // Initialize the (exportable) env. - 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; @@ -451,7 +537,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); } @@ -461,162 +548,198 @@ 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) { + pmpmi = calloc(1, sizeof(pmp_music_internal_t)); + if (!pmpmi) { + free(music); return PMPDBE_OUTOFMEMORY; } - pp1db_init(&pmpdbi->pp1db, pmpi->env.hdr_initproc); + pp1db_init(&pmpmi->pp1db, pmpi->decl->hdr_initproc); - 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) -{ - pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance; - pmp_playlist_t* pmppl = NULL; - *ptr_pmppl = 0; - pmppl = calloc(1, sizeof(pmp_playlist_t)); - if (!pmppl) { - return PMPDBE_OUTOFMEMORY; - } - pmppl->add_ref = pmppl_add_ref; - pmppl->release = pmppl_release; - pmppl->write = pmppl_write; - - pmppl->pmp = pmp; - - pmppl->add_ref(pmppl); - *ptr_pmppl = pmppl; +static uint32_t pmpmusic_release(pmp_music_t* music) +{ + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + pp1db_finish(&pmpmi->pp1db); + pmplib_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. + 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 hdr[MAX_PATH]; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance; + // Read the music database. + set_filenames(hdr, pmp); + ret = pp1db_read(&pmpmi->pp1db, hdr); + if (ret) { + return ret; + } -static uint32_t pmpdb_release(pmp_music_t* pmpdb) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - pp1db_finish(&pmpdbi->pp1db); - free(pmpdb->instance); - free(pmpdb); + return pp1db_get(&pmpmi->pp1db, pmpmi->records, &pmpmi->num_records, pmp->info.path_to_root); + } + return 0; } -static result_t pmpdb_read(pmp_music_t* pmpdb) +static uint32_t pmpmusic_close(pmp_music_t* music) { - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return pp1db_read(&pmpdbi->pp1db, pmpi->env.hdr_filename); -} + 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}; -static result_t pmpdb_write(pmp_music_t* pmpdb) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - pmp_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return pp1db_write(&pmpdbi->pp1db, pmpi->env.hdr_filename); -} + if (pmp->flag & PMPOF_MUSIC_DB_WRITE) { + ucs2char_t hdr[MAX_PATH]; -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_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return pp1db_set(&pmpdbi->pp1db, records, num_records, pmpi->env.path_to_root); -} + pp1db_set(&pmpmi->pp1db, pmpmi->records, pmpmi->num_records, pmp->info.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_internal_t* pmpi = (pmp_internal_t*)pmpdb->pmp->instance; - return pp1db_get(&pmpdbi->pp1db, records, num_records, pmpi->env.path_to_root); -} + set_filenames(hdr, pmp); + ret = pp1db_write(&pmpmi->pp1db, hdr); + if (ret) { + return ret; + } + } -static result_t pmpdb_dump(pmp_music_t* pmpdb, FILE *fp, int level) -{ - pmpdb_internal_t* pmpdbi = (pmpdb_internal_t*)pmpdb->instance; - return pp1db_repr(&pmpdbi->pp1db, fp, level); -} + if (pmp->flag & PMPOF_MUSIC_PL_WRITE) { + int i; -static int pmpdb_is_supported_codec(pmp_music_t* pmpdb, uint32_t codec) -{ - return pp1db_is_supported_codec(codec); + for (i = 0;i < pmpmi->num_playlists;++i) { + const pmp_playlist_t* pl = &pmpmi->playlists[i]; + if (pp1db_playlist_write( + &pmpmi->pp1db, + 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 int pmpdb_is_supported_ext(pmp_music_t* pmpdb, const ucs2char_t* filename) +static result_t pmpmusic_set_records(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records) { - return pp1db_is_supported_ext(filename); -} + 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); -static uint32_t pmppl_add_ref(pmp_playlist_t* pmppl) + return 0; + } + +static result_t pmpmusic_get_records(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records) { - return pmplib_interlocked_increment(&pmppl->ref_count); + 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 uint32_t pmppl_release(pmp_playlist_t* pmppl) +static result_t pmpmusic_dump(pmp_music_t* music, FILE *fp, int level) { - uint32_t count = pmplib_interlocked_decrement(&pmppl->ref_count); - if (count == 0) { - free(pmppl); - } - return count; + pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance; + return pp1db_repr(&pmpmi->pp1db, fp, level); } -static result_t pmppl_write(pmp_playlist_t* pmppl, const ucs2char_t* filename, ucs2char_t* const files[], uint32_t num_files) +static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists) { - pmp_internal_t* pmpi = (pmp_internal_t*)pmppl->pmp->instance; - if (playlist_write(filename, files, num_files, pmpi->env.path_to_root) != 0) { - return PMPPLE_WRITE; - } + 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); + return 0; } Modified: trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2007-01-26 02:36:01 UTC (rev 281) +++ trunk/pmplib/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2007-01-26 03:44:58 UTC (rev 282) @@ -206,34 +206,6 @@ > </File> <File - RelativePath=".\model_iriver_h10.c" - > - </File> - <File - RelativePath=".\model_medion_mdjuke220.c" - > - </File> - <File - RelativePath=".\model_medion_mdjuke440.c" - > - </File> - <File - RelativePath=".\model_msi_megaplayer.c" - > - </File> - <File - RelativePath=".\model_philips_hdd6320.c" - > - </File> - <File - RelativePath=".\model_samsung.c" - > - </File> - <File - RelativePath=".\model_sirius_s50.c" - > - </File> - <File RelativePath=".\playlist.c" > </File> @@ -286,6 +258,38 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > </Filter> + <Filter + Name="Model" + > + <File + RelativePath=".\model_iriver_h10.c" + > + </File> + <File + RelativePath=".\model_medion_mdjuke220.c" + > + </File> + <File + RelativePath=".\model_medion_mdjuke440.c" + > + </File> + <File + RelativePath=".\model_msi_megaplayer.c" + > + </File> + <File + RelativePath=".\model_philips_hdd6320.c" + > + </File> + <File + RelativePath=".\model_samsung.c" + > + </File> + <File + RelativePath=".\model_sirius_s50.c" + > + </File> + </Filter> </Files> <Globals> </Globals> Modified: trunk/pmplib/lib/pmp_portalplayer1/pp1db.h =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/pp1db.h 2007-01-26 02:36:01 UTC (rev 281) +++ trunk/pmplib/lib/pmp_portalplayer1/pp1db.h 2007-01-26 03:44:58 UTC (rev 282) @@ -149,11 +149,14 @@ void idx_repr(const idx_t* elem, FILE *fp); // playlist.c -int playlist_write( - const ucs2char_t *filename, +int pp1db_playlist_write( + pp1db_t* db, + 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 ); // pp1db.c 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 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 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 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-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-25 03:06:50
|
Revision: 276 http://svn.sourceforge.net/pmplib/?rev=276&view=rev Author: nyaochi Date: 2007-01-24 19:06:49 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Document playlist reader/writer API. Modified Paths: -------------- trunk/pmplib/include/pmp.h Modified: trunk/pmplib/include/pmp.h =================================================================== --- trunk/pmplib/include/pmp.h 2007-01-25 02:29:25 UTC (rev 275) +++ trunk/pmplib/include/pmp.h 2007-01-25 03:06:49 UTC (rev 276) @@ -398,10 +398,67 @@ */ result_t (*get_records)(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records); + /** + * Set a list of music playlists. + * + * This function sets a list of music playlists. PMPlib will generate the + * playlists on the device based on this list. + * + * This function does not write out any content on the player immediately; + * playlist generation is prolonged until the device is closed by + * pmp->close() call. + * + * @param music The pointer to the pmp_music_t interface. + * @param playlists An array of music playlists. + * @param num_playlists The number of elements in \a playlists array. + * @retval result_t The status code after this operation. + * + * @assert + * @code music != NULL @endcode + * @code playlists != NULL @endcode + */ result_t (*set_playlists)(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists); + + /** + * Get a list of music playlists. + * + * This function gets the list of music playlists in the device or set by + * \a set_playlists call. + * + * If the argument \a playlists is NULL, this function returns the number + * of music playlists to the variable whose address is specified by the + * argument \a num_playlists. You can use this for determining the size of + * array \a playlists necessary to obtain all playlists. + * + * If the argument \a playlists is not NULL, this function copies the + * current music playlists to the array whose address is specified by the + * argument \a playlists and whose size is specified by the variable + * pointed by the argument \a num_playlists. + * + * @param music The pointer to the pmp_music_t interface. + * @param playlists An array of music playlists. + * @param num_playlists The pointer to the variable presenting the + * number of elements in \a playlists array. + * @retval result_t The status code after this operation. + * + * @assert + * @code music != NULL @endcode + * @code num_playlists != NULL @endcode + */ result_t (*get_playlists)(pmp_music_t* music, pmp_playlist_t* playlists, uint32_t* num_playlists); - result_t (*dump)(pmp_music_t* pmpdb, FILE *fp, int level); + /** + * Dump the music database. + * + * @param music The pointer to the pmp_music_t interface. + * @param fp The pointer to an output stream. + * @param flag The flags. + * @retval result_t The status code after this operation. + * + * @assert + * @code music != NULL @endcode + */ + result_t (*dump)(pmp_music_t* music, FILE *fp, int flag); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |