From: <ny...@us...> - 2007-03-06 04:23:32
|
Revision: 403 http://svn.sourceforge.net/pmplib/?rev=403&view=rev Author: nyaochi Date: 2007-03-05 20:23:18 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Make the SVN head build on POSIX for debugging iriver E10 database problem. Now libmp4v2 is necessary (but should be omittable later). Modified Paths: -------------- trunk/pmplib/configure.in trunk/pmplib/frontend/easypmp/cui/Makefile.am trunk/pmplib/lib/filepath/filepath_posix.c trunk/pmplib/lib/gmi/Makefile.am trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/configure.in =================================================================== --- trunk/pmplib/configure.in 2007-02-28 12:21:46 UTC (rev 402) +++ trunk/pmplib/configure.in 2007-03-06 04:23:18 UTC (rev 403) @@ -184,6 +184,19 @@ dnl Checks for vorbis AM_PATH_VORBIS +dnl Checks for libmp4v2 +AC_CHECK_HEADER( + mp4.h, + , + [AC_MSG_ERROR(mp4v2 header not found!)] +) +AC_CHECK_LIB( + mp4v2, + MP4Read, + [MP4V2_LIBS="-lmp4v2"], + AC_MSG_ERROR([mp4v2 library is not found!]) +) + dnl Check for libsmjs (SpiderMonkey JavaScript engine) AC_PATH_SPIDERMONKEY @@ -219,6 +232,7 @@ AC_SUBST(OGG_LIBS) AC_SUBST(VORBIS_LIBS) AC_SUBST(VORBISFILE_LIBS) +AC_SUBST(MP4V2_LIBS) AC_SUBST(JS_CFLAGS) AC_SUBST(JS_LIBS) AC_SUBST(JS_RPATH) Modified: trunk/pmplib/frontend/easypmp/cui/Makefile.am =================================================================== --- trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-28 12:21:46 UTC (rev 402) +++ trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-03-06 04:23:18 UTC (rev 403) @@ -13,6 +13,7 @@ ../common/database.c \ ../common/enumerate.c \ ../common/playlist.c \ + ../common/settle.c \ device.c \ option.c \ option.h \ @@ -35,4 +36,5 @@ easypmp_LDADD = \ $(top_builddir)/lib/pmp/libpmp.la \ $(top_builddir)/lib/gmi/libgmi.la \ - $(top_builddir)/lib/playlist/libplaylist.la + $(top_builddir)/lib/playlist/libplaylist.la \ + $(JS_LIBS) Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-28 12:21:46 UTC (rev 402) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-03-06 04:23:18 UTC (rev 403) @@ -37,6 +37,8 @@ #include <pmplib/filepath.h> #include "rel2abs.h" +static const ucs2char_t ucs2cs_link_ext[] = {'.','m','3','u','8',0}; + static int _decode(char* path) { while (*path) { @@ -189,10 +191,17 @@ return dst; } -const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root) +const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root, int pathchar) { - if (ucs2ncmp(path, root, ucs2len(root)) == 0) { - return path + ucs2len(root); + /* Make sure the _root ends with a PATHCHAR. */ + ucs2char_t* _root = alloca(sizeof(ucs2char_t) * (ucs2len(root) + 2)); + ucs2cpy(_root, root); + filepath_addslash(_root); + + if (ucs2ncmp(path, _root, ucs2len(_root)) == 0) { + const ucs2char_t* p = path + ucs2len(_root); + if (pathchar) --p; + return p < path ? path : p; } else { return path; } @@ -204,22 +213,18 @@ return p ? p+1 : path; } -const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root) -{ - const ucs2char_t* p = filepath_skiproot(path, root); - if (p == NULL) p = path; - if (path < p && p[-1] == PATHCHAR) { - --p; - } - return p; -} - const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path) { ucs2char_t* p = ucs2chr(path, PATHCHAR); return p ? p+1 : NULL; } +const ucs2char_t* filepath_extract_extension(const ucs2char_t* path) +{ + ucs2char_t* p = ucs2rchr(path, '.'); + return p ? p : path; +} + void filepath_strippath(ucs2char_t* path) { ucs2char_t* p = path + ucs2len(path) - 1; @@ -316,6 +321,18 @@ return (ret1 - ret2); } +int filepath_createdirs(const ucs2char_t* filename) +{ + ucs2char_t* dirname = (ucs2char_t*)alloca(sizeof(ucs2char_t) * (ucs2len(filename) + 1)); + filepath_removeslash(dirname); + if (filepath_file_exists(dirname)) { + return 0; + } else { + filepath_remove_filespec(dirname); + return filepath_createdirs(dirname); + } +} + int filepath_copyfile(const ucs2char_t* src, const ucs2char_t* dst) { int ret = 0; @@ -354,6 +371,79 @@ return ret; } +int filepath_movefile(const ucs2char_t* src, const ucs2char_t* dst) +{ + int ret = 0; + char *_src = ucs2dupmbs(src); + char *_dst = ucs2dupmbs(dst); + ret = (rename(_src, _dst) == 0); + ucs2free(_dst); + ucs2free(_src); + return ret; +} + +int filepath_linkfile(const ucs2char_t* target, const ucs2char_t* link) +{ + /* Create a m3u8 playlist with the target file. */ + FILE *fp = NULL; + ucs2char_t* _link = alloca(sizeof(ucs2char_t) * (ucs2len(link) + ucs2len(ucs2cs_link_ext) + 1)); + + /* Add ".m3u8" extension. */ + ucs2cpy(_link, link); + ucs2cat(_link, ucs2cs_link_ext); + + /* Write the */ + fp = ucs2fopen(_link, "w"); + if (fp) { + char *utf8 = ucs2duputf8(target); + fputc('\\', fp); + fputs(utf8, fp); + ucs2free(utf8); + fclose(fp); + return 0; + } else { + return -1; + } +} + +int filepath_followlink(const ucs2char_t* link, ucs2char_t* org) +{ + /* Create a m3u8 playlist with the target file. */ + FILE *fp = NULL; + ucs2char_t* _link = (ucs2char_t*)alloca( + sizeof(ucs2char_t) * (ucs2len(link) + ucs2len(ucs2cs_link_ext) + 1)); + + /* Add ".m3u8" extension. */ + ucs2cpy(_link, link); + ucs2cat(_link, ucs2cs_link_ext); + + /* Write the */ + fp = ucs2fopen(_link, "r"); + if (fp) { + char buff[MAX_PATH*4]; + ucs2char_t target[MAX_PATH]; + fgets(buff, sizeof(buff)-1, fp); + utf8toucs2(target, MAX_PATH, buff, strlen(buff)+1); + filepath_combinepath(org, MAX_PATH, link, target); + fclose(fp); + return 0; + } else { + return -1; + } +} + +int filepath_removelinkfile(const ucs2char_t* file) +{ + ucs2char_t* _link = (ucs2char_t*)alloca( + sizeof(ucs2char_t) * (ucs2len(file) + ucs2len(ucs2cs_link_ext) + 1)); + + /* Add ".m3u8" extension. */ + ucs2cpy(_link, file); + ucs2cat(_link, ucs2cs_link_ext); + + return filepath_removefile(_link); +} + int filepath_encode(ucs2char_t* path) { while (*path) { @@ -426,3 +516,8 @@ } return 0; } + +int filepath_is_link(const ucs2char_t *path) +{ + return filepath_hasext(path, ucs2cs_link_ext); +} Modified: trunk/pmplib/lib/gmi/Makefile.am =================================================================== --- trunk/pmplib/lib/gmi/Makefile.am 2007-02-28 12:21:46 UTC (rev 402) +++ trunk/pmplib/lib/gmi/Makefile.am 2007-03-06 04:23:18 UTC (rev 403) @@ -5,6 +5,7 @@ libgmi_la_SOURCES = \ ../../include/gmi.h \ gmi_mp3.c \ + gmi_mp4v2.c \ gmi_wma.c \ gmi_wav.c \ gmi_vorbis.c \ @@ -12,7 +13,7 @@ libgmi_la_LDFLAGS = \ @ID3TAG_LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @VORBISFILE_LIBS@ \ - -no-undefined + @MP4V2_LIBS@ -no-undefined AM_CFLAGS = @CFLAGS@ INCLUDES = @INCLUDES@ Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-28 12:21:46 UTC (rev 402) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-03-06 04:23:18 UTC (rev 403) @@ -237,6 +237,13 @@ return ret; } +size_t ucs2toutf8(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size) +{ + iconv_t cd = iconv_open("UTF-8", g_ucs2encoding); + size_t ret = iconv_convert(cd, (char **)&mbstr, mbs_size, (char **)&ucs2str, ucs_size * sizeof(ucs2char_t)); + iconv_close(cd); + return ret; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |