diff -Nru libmpdclient-2.2/configure libmpdclient-2.3/configure --- libmpdclient-2.2/configure 2010-04-26 06:22:18.000000000 +0530 +++ libmpdclient-2.3/configure 2010-07-25 22:50:44.000000000 +0530 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for libmpdclient 2.2. +# Generated by GNU Autoconf 2.65 for libmpdclient 2.3. # # Report bugs to . # @@ -701,8 +701,8 @@ # Identity of this package. PACKAGE_NAME='libmpdclient' PACKAGE_TARNAME='libmpdclient' -PACKAGE_VERSION='2.2' -PACKAGE_STRING='libmpdclient 2.2' +PACKAGE_VERSION='2.3' +PACKAGE_STRING='libmpdclient 2.3' PACKAGE_BUGREPORT='musicpd-dev-team@lists.sourceforge.net' PACKAGE_URL='' @@ -1431,7 +1431,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libmpdclient 2.2 to adapt to many kinds of systems. +\`configure' configures libmpdclient 2.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1501,7 +1501,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libmpdclient 2.2:";; + short | recursive ) echo "Configuration of libmpdclient 2.3:";; esac cat <<\_ACEOF @@ -1607,7 +1607,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libmpdclient configure 2.2 +libmpdclient configure 2.3 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1885,7 +1885,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libmpdclient $as_me 2.2, which was +It was created by libmpdclient $as_me 2.3, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2694,7 +2694,7 @@ # Define the identity of the package. PACKAGE='libmpdclient' - VERSION='2.2' + VERSION='2.3' cat >>confdefs.h <<_ACEOF @@ -2740,12 +2740,12 @@ MAJOR_VERSION=2 -MINOR_VERSION=2 +MINOR_VERSION=3 PATCH_VERSION=0 -LIBMPDCLIENT_LIBTOOL_VERSION=2:0:0 +LIBMPDCLIENT_LIBTOOL_VERSION=2:1:0 # Remove the check for c++ and fortran compiler @@ -11025,7 +11025,7 @@ -WANTED_CFLAGS="-Wall -W -Wextra -Wno-deprecated-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wwrite-strings" +WANTED_CFLAGS="-Wall -W -Wextra -Wno-deprecated-declarations -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wwrite-strings" for flag in $WANTED_CFLAGS ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 $as_echo_n "checking whether C compiler accepts $flag... " >&6; } @@ -11651,7 +11651,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libmpdclient $as_me 2.2, which was +This file was extended by libmpdclient $as_me 2.3, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11717,7 +11717,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libmpdclient config.status 2.2 +libmpdclient config.status 2.3 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff -Nru libmpdclient-2.2/configure.ac libmpdclient-2.3/configure.ac --- libmpdclient-2.2/configure.ac 2010-04-26 06:20:47.000000000 +0530 +++ libmpdclient-2.3/configure.ac 2010-07-25 22:50:35.000000000 +0530 @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(libmpdclient, 2.2, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(libmpdclient, 2.3, musicpd-dev-team@lists.sourceforge.net) AC_CONFIG_SRCDIR([src/connection.c]) AC_CONFIG_AUX_DIR(build) AM_INIT_AUTOMAKE([foreign 1.10 dist-bzip2 subdir-objects]) @@ -7,10 +7,10 @@ AC_CONFIG_MACRO_DIR([m4]) AC_SUBST(MAJOR_VERSION,2) -AC_SUBST(MINOR_VERSION,2) +AC_SUBST(MINOR_VERSION,3) AC_SUBST(PATCH_VERSION,0) -LIBMPDCLIENT_LIBTOOL_VERSION=2:0:0 +LIBMPDCLIENT_LIBTOOL_VERSION=2:1:0 AC_SUBST(LIBMPDCLIENT_LIBTOOL_VERSION) # Remove the check for c++ and fortran compiler @@ -92,7 +92,7 @@ AC_SUBST(AM_CFLAGS) AC_SUBST(AM_CPPFLAGS) -WANTED_CFLAGS="-Wall -W -Wextra -Wno-deprecated-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wwrite-strings" +WANTED_CFLAGS="-Wall -W -Wextra -Wno-deprecated-declarations -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wwrite-strings" for flag in $WANTED_CFLAGS ; do AX_CHECK_COMPILER_FLAGS([$flag], [CFLAGS="$CFLAGS $flag"],) done diff -Nru libmpdclient-2.2/debian/changelog libmpdclient-2.3/debian/changelog --- libmpdclient-2.2/debian/changelog 2010-08-26 17:05:58.000000000 +0530 +++ libmpdclient-2.3/debian/changelog 2010-08-26 17:05:59.000000000 +0530 @@ -1,3 +1,16 @@ +libmpdclient (2.3-1) unstable; urgency=low + + * New upstream release. + - Do not try to install GIF files from doc/api/html/ if none are available + (doxygen no longer creates any GIF files since version 1.7 or so) + (Closes: #590397). + * debian/control: + - Updated standards-version to 3.9.1 -- no changes. + * debian/libmpdclient2.symbols: + - Updated for 2.3. + + -- Sebastian Harl Thu, 29 Jul 2010 20:39:38 +0200 + libmpdclient (2.2-1) unstable; urgency=low * New upstream release. diff -Nru libmpdclient-2.2/debian/control libmpdclient-2.3/debian/control --- libmpdclient-2.2/debian/control 2010-08-26 17:05:58.000000000 +0530 +++ libmpdclient-2.3/debian/control 2010-08-26 17:05:59.000000000 +0530 @@ -3,7 +3,7 @@ Priority: optional Maintainer: Sebastian Harl Build-Depends: debhelper (>= 7), autotools-dev, doxygen -Standards-Version: 3.8.4 +Standards-Version: 3.9.1 Homepage: http://mpd.wikia.com/wiki/ClientLib:libmpdclient Vcs-Git: git://git.tokkee.org/pkg-libmpdclient.git Vcs-Browser: http://git.tokkee.org/?p=pkg-libmpdclient.git diff -Nru libmpdclient-2.2/debian/libmpdclient2.symbols libmpdclient-2.3/debian/libmpdclient2.symbols --- libmpdclient-2.2/debian/libmpdclient2.symbols 2010-08-26 17:05:58.000000000 +0530 +++ libmpdclient-2.3/debian/libmpdclient2.symbols 2010-08-26 17:05:59.000000000 +0530 @@ -225,9 +225,11 @@ mpd_song_feed@libmpdclient2 2.0 mpd_song_free@libmpdclient2 2.0 mpd_song_get_duration@libmpdclient2 2.0 + mpd_song_get_end@libmpdclient2 2.3 mpd_song_get_id@libmpdclient2 2.0 mpd_song_get_last_modified@libmpdclient2 2.0 mpd_song_get_pos@libmpdclient2 2.0 + mpd_song_get_start@libmpdclient2 2.3 mpd_song_get_tag@libmpdclient2 2.0 mpd_song_get_uri@libmpdclient2 2.0 mpd_song_set_pos@libmpdclient2 2.0 diff -Nru libmpdclient-2.2/include/mpd/connection.h libmpdclient-2.3/include/mpd/connection.h --- libmpdclient-2.2/include/mpd/connection.h 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/include/mpd/connection.h 2010-07-25 22:50:35.000000000 +0530 @@ -84,11 +84,15 @@ * @param host the server's host name, IP address or Unix socket path. * If the resolver returns more than one IP address for a host name, * this functions tries all of them until one accepts the connection. - * NULL is allowed here, which will connect to the default host. - * @param port the TCP port to connect to, 0 for default port. If - * "host" is a Unix socket path, this parameter is ignored. + * NULL is allowed here, which will connect to the default host + * (using the MPD_HOST environment variable if present). + * @param port the TCP port to connect to, 0 for default port (using + * the MPD_PORT environment variable if present). If "host" is a Unix + * socket path, this parameter is ignored. * @param timeout_ms the timeout in milliseconds, 0 for the default - * timeout; you may modify it later with mpd_connection_set_timeout() + * timeout (the environment variable MPD_TIMEOUT may specify a timeout + * in seconds); you may modify it later with + * mpd_connection_set_timeout() * @return a mpd_connection object (which may have failed to connect), * or NULL on out-of-memory */ diff -Nru libmpdclient-2.2/include/mpd/song.h libmpdclient-2.3/include/mpd/song.h --- libmpdclient-2.2/include/mpd/song.h 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/include/mpd/song.h 2010-07-25 22:50:35.000000000 +0530 @@ -109,6 +109,23 @@ mpd_song_get_duration(const struct mpd_song *song); /** + * Returns the start of the virtual song within the physical file in + * seconds. + */ +mpd_pure +unsigned +mpd_song_get_start(const struct mpd_song *song); + +/** + * Returns the end of the virtual song within the physical file in + * seconds. Zero means that the physical song file is played to the + * end. + */ +mpd_pure +unsigned +mpd_song_get_end(const struct mpd_song *song); + +/** * @return the POSIX UTC time stamp of the last modification, or 0 if * that is unknown */ diff -Nru libmpdclient-2.2/include/mpd/version.h libmpdclient-2.3/include/mpd/version.h --- libmpdclient-2.2/include/mpd/version.h 2010-04-26 06:22:25.000000000 +0530 +++ libmpdclient-2.3/include/mpd/version.h 2010-07-25 22:50:48.000000000 +0530 @@ -36,7 +36,7 @@ #define MPD_VERSION_H #define LIBMPDCLIENT_MAJOR_VERSION 2 -#define LIBMPDCLIENT_MINOR_VERSION 2 +#define LIBMPDCLIENT_MINOR_VERSION 3 #define LIBMPDCLIENT_PATCH_VERSION 0 /** diff -Nru libmpdclient-2.2/libmpdclient.ld libmpdclient-2.3/libmpdclient.ld --- libmpdclient-2.2/libmpdclient.ld 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/libmpdclient.ld 2010-07-25 22:50:35.000000000 +0530 @@ -247,6 +247,8 @@ mpd_song_get_uri; mpd_song_get_tag; mpd_song_get_duration; + mpd_song_get_start; + mpd_song_get_end; mpd_song_get_last_modified; mpd_song_set_pos; mpd_song_get_pos; diff -Nru libmpdclient-2.2/Makefile.am libmpdclient-2.3/Makefile.am --- libmpdclient-2.2/Makefile.am 2010-04-26 06:20:42.000000000 +0530 +++ libmpdclient-2.3/Makefile.am 2010-07-25 22:50:35.000000000 +0530 @@ -81,7 +81,8 @@ src/cstats.c \ src/sync.c src/sync.h \ src/tag.c \ - src/sticker.c + src/sticker.c \ + src/uri.h src_libmpdclient_la_LDFLAGS = -version-info @LIBMPDCLIENT_LIBTOOL_VERSION@ \ -no-undefined @@ -130,8 +131,10 @@ if DOXYGEN -doc/api/html/index.html: doc/doxygen.conf $(wildcard include/mpd/*.h) - $(DOXYGEN) $< +doc/api/html/index.html: doc/doxygen.conf + @mkdir -p $(@D) + [ "$(srcdir)" = "." ] || sed '/INPUT *=/ s/\([^ ]\+\/\)/$(subst /,\/,$(srcdir))\/\1/g' $(srcdir)/doc/doxygen.conf >doc/doxygen.conf + $(DOXYGEN) doc/doxygen.conf all-local: doc/api/html/index.html @@ -140,15 +143,11 @@ install-data-local: doc/api/html/index.html $(mkinstalldirs) $(DESTDIR)$(docdir)/html - $(INSTALL_DATA) -c -m 644 doc/api/html/*.html doc/api/html/*.css \ - doc/api/html/*.png doc/api/html/*.gif \ + $(INSTALL_DATA) -c -m 644 doc/api/html/*.* \ $(DESTDIR)$(docdir)/html uninstall-local: - rm -f $(DESTDIR)$(docdir)/html/*.html \ - $(DESTDIR)$(docdir)/html/*.css \ - $(DESTDIR)$(docdir)/html/*.gif \ - $(DESTDIR)$(docdir)/html/*.png + rm -f $(DESTDIR)$(docdir)/html/*.* upload: doc/api/html/index.html rsync -vpruz --delete doc/api/html/ \ diff -Nru libmpdclient-2.2/Makefile.in libmpdclient-2.3/Makefile.in --- libmpdclient-2.2/Makefile.in 2010-04-26 06:22:20.000000000 +0530 +++ libmpdclient-2.3/Makefile.in 2010-07-25 22:50:44.000000000 +0530 @@ -349,7 +349,8 @@ src/cstats.c \ src/sync.c src/sync.h \ src/tag.c \ - src/sticker.c + src/sticker.c \ + src/uri.h src_libmpdclient_la_LDFLAGS = -version-info \ @LIBMPDCLIENT_LIBTOOL_VERSION@ -no-undefined $(am__append_1) @@ -1266,8 +1267,10 @@ sparse-check: $(SPARSE) -I. $(CFLAGS) $(AM_CPPFLAGS) $(SPARSE_FLAGS) $(SPARSE_CPPFLAGS) $(addprefix $(srcdir)/,$(src_libmpdclient_la_SOURCES)) -@DOXYGEN_TRUE@doc/api/html/index.html: doc/doxygen.conf $(wildcard include/mpd/*.h) -@DOXYGEN_TRUE@ $(DOXYGEN) $< +@DOXYGEN_TRUE@doc/api/html/index.html: doc/doxygen.conf +@DOXYGEN_TRUE@ @mkdir -p $(@D) +@DOXYGEN_TRUE@ [ "$(srcdir)" = "." ] || sed '/INPUT *=/ s/\([^ ]\+\/\)/$(subst /,\/,$(srcdir))\/\1/g' $(srcdir)/doc/doxygen.conf >doc/doxygen.conf +@DOXYGEN_TRUE@ $(DOXYGEN) doc/doxygen.conf @DOXYGEN_TRUE@all-local: doc/api/html/index.html @@ -1276,15 +1279,11 @@ @DOXYGEN_TRUE@install-data-local: doc/api/html/index.html @DOXYGEN_TRUE@ $(mkinstalldirs) $(DESTDIR)$(docdir)/html -@DOXYGEN_TRUE@ $(INSTALL_DATA) -c -m 644 doc/api/html/*.html doc/api/html/*.css \ -@DOXYGEN_TRUE@ doc/api/html/*.png doc/api/html/*.gif \ +@DOXYGEN_TRUE@ $(INSTALL_DATA) -c -m 644 doc/api/html/*.* \ @DOXYGEN_TRUE@ $(DESTDIR)$(docdir)/html @DOXYGEN_TRUE@uninstall-local: -@DOXYGEN_TRUE@ rm -f $(DESTDIR)$(docdir)/html/*.html \ -@DOXYGEN_TRUE@ $(DESTDIR)$(docdir)/html/*.css \ -@DOXYGEN_TRUE@ $(DESTDIR)$(docdir)/html/*.gif \ -@DOXYGEN_TRUE@ $(DESTDIR)$(docdir)/html/*.png +@DOXYGEN_TRUE@ rm -f $(DESTDIR)$(docdir)/html/*.* @DOXYGEN_TRUE@upload: doc/api/html/index.html @DOXYGEN_TRUE@ rsync -vpruz --delete doc/api/html/ \ diff -Nru libmpdclient-2.2/NEWS libmpdclient-2.3/NEWS --- libmpdclient-2.2/NEWS 2010-04-26 06:22:14.000000000 +0530 +++ libmpdclient-2.3/NEWS 2010-07-25 22:50:42.000000000 +0530 @@ -1,3 +1,8 @@ +libmpdclient 2.3 (2010/05/25) +* get default timeout from environment variable MPD_TIMEOUT +* fix assertion failures on malformed URI +* song: support attribute "Range" + libmpdclient 2.2 (2010/04/25) * MixRamp support * fix the LIBMPDCLIENT_CHECK_VERSION() macro diff -Nru libmpdclient-2.2/src/connection.c libmpdclient-2.3/src/connection.c --- libmpdclient-2.2/src/connection.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/connection.c 2010-07-25 22:50:35.000000000 +0530 @@ -188,6 +188,20 @@ return mpd_socket_connect(host, port, timeout, error); } +static unsigned +mpd_default_timeout_ms(void) +{ + const char *timeout_string = getenv("MPD_TIMEOUT"); + if (timeout_string != NULL) { + int timeout_s = atoi(timeout_string); + if (timeout_s > 0) + return timeout_s * 1000; + } + + /* 30s is the default */ + return 30000; +} + struct mpd_connection * mpd_connection_new(const char *host, unsigned port, unsigned timeout_ms) { @@ -213,8 +227,7 @@ return connection; if (timeout_ms == 0) - /* 30s is the default */ - timeout_ms = 30000; + timeout_ms = mpd_default_timeout_ms(); mpd_connection_set_timeout(connection, timeout_ms); diff -Nru libmpdclient-2.2/src/directory.c libmpdclient-2.3/src/directory.c --- libmpdclient-2.2/src/directory.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/directory.c 2010-07-25 22:50:35.000000000 +0530 @@ -32,10 +32,12 @@ #include #include +#include "uri.h" #include #include #include +#include struct mpd_directory { /** @@ -52,9 +54,7 @@ struct mpd_directory *directory; assert(path != NULL); - assert(*path != '/'); - assert(*path != 0); - assert(path[strlen(path) - 1] != '/'); + assert(mpd_verify_local_uri(path)); directory = malloc(sizeof(*directory)); if (directory == NULL) @@ -105,8 +105,11 @@ assert(pair->name != NULL); assert(pair->value != NULL); - if (strcmp(pair->name, "directory") != 0) + if (strcmp(pair->name, "directory") != 0 || + !mpd_verify_local_uri(pair->value)) { + errno = EINVAL; return NULL; + } return mpd_directory_new(pair->value); } diff -Nru libmpdclient-2.2/src/entity.c libmpdclient-2.3/src/entity.c --- libmpdclient-2.2/src/entity.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/entity.c 2010-07-25 22:50:35.000000000 +0530 @@ -36,6 +36,7 @@ #include #include +#include struct mpd_entity { /** @@ -216,7 +217,7 @@ entity = mpd_entity_begin(pair); mpd_return_pair(connection, pair); if (entity == NULL) { - mpd_error_code(&connection->error, MPD_ERROR_OOM); + mpd_error_entity(&connection->error); return NULL; } diff -Nru libmpdclient-2.2/src/ierror.c libmpdclient-2.3/src/ierror.c --- libmpdclient-2.2/src/ierror.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/ierror.c 2010-07-25 22:50:35.000000000 +0530 @@ -2,7 +2,7 @@ (c) 2003-2010 The Music Player Daemon Project This project's homepage is: http://www.musicpd.org - Redistribution and use in source and binary forms, with or without + Redistribution and use in so and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -33,6 +33,7 @@ #include #include #include +#include void mpd_error_deinit(struct mpd_error_info *error) @@ -120,6 +121,16 @@ mpd_error_system_message(error, mpd_socket_errno()); } +void +mpd_error_entity(struct mpd_error_info *error) +{ + if (errno == EINVAL) { + mpd_error_code(error, MPD_ERROR_MALFORMED); + mpd_error_message(error, "Malformed entity response line"); + } else + mpd_error_code(error, MPD_ERROR_OOM); +} + bool mpd_error_copy(struct mpd_error_info *dest, const struct mpd_error_info *src) { diff -Nru libmpdclient-2.2/src/ierror.h libmpdclient-2.3/src/ierror.h --- libmpdclient-2.2/src/ierror.h 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/ierror.h 2010-07-25 22:50:35.000000000 +0530 @@ -205,6 +205,13 @@ mpd_error_errno(struct mpd_error_info *error); /** + * An entity parser has failed. The error is set depending on the + * value of errno (ENOMEM or EINVAL). + */ +void +mpd_error_entity(struct mpd_error_info *error); + +/** * Copies a #mpd_error_info onto another one. Duplicates the error * message. * diff -Nru libmpdclient-2.2/src/playlist.c libmpdclient-2.3/src/playlist.c --- libmpdclient-2.2/src/playlist.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/playlist.c 2010-07-25 22:50:35.000000000 +0530 @@ -33,10 +33,12 @@ #include #include #include "iso8601.h" +#include "uri.h" #include #include #include +#include struct mpd_playlist { char *path; @@ -54,9 +56,7 @@ struct mpd_playlist *playlist; assert(path != NULL); - assert(*path != '/'); - assert(*path != 0); - assert(path[strlen(path) - 1] != '/'); + assert(mpd_verify_local_uri(path)); playlist = malloc(sizeof(*playlist)); if (playlist == NULL) @@ -113,8 +113,11 @@ assert(pair->name != NULL); assert(pair->value != NULL); - if (strcmp(pair->name, "playlist") != 0) + if (strcmp(pair->name, "playlist") != 0 || + !mpd_verify_local_uri(pair->value)) { + errno = EINVAL; return NULL; + } return mpd_playlist_new(pair->value); } diff -Nru libmpdclient-2.2/src/rdirectory.c libmpdclient-2.3/src/rdirectory.c --- libmpdclient-2.2/src/rdirectory.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/rdirectory.c 2010-07-25 22:50:35.000000000 +0530 @@ -30,6 +30,8 @@ #include #include "internal.h" +#include + struct mpd_directory * mpd_recv_directory(struct mpd_connection *connection) { @@ -43,7 +45,7 @@ directory = mpd_directory_begin(pair); mpd_return_pair(connection, pair); if (directory == NULL) { - mpd_error_code(&connection->error, MPD_ERROR_OOM); + mpd_error_entity(&connection->error); return NULL; } diff -Nru libmpdclient-2.2/src/rplaylist.c libmpdclient-2.3/src/rplaylist.c --- libmpdclient-2.2/src/rplaylist.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/rplaylist.c 2010-07-25 22:50:35.000000000 +0530 @@ -30,6 +30,8 @@ #include #include "internal.h" +#include + struct mpd_playlist * mpd_recv_playlist(struct mpd_connection *connection) { @@ -43,7 +45,7 @@ playlist = mpd_playlist_begin(pair); mpd_return_pair(connection, pair); if (playlist == NULL) { - mpd_error_code(&connection->error, MPD_ERROR_OOM); + mpd_error_entity(&connection->error); return NULL; } diff -Nru libmpdclient-2.2/src/song.c libmpdclient-2.3/src/song.c --- libmpdclient-2.2/src/song.c 2010-04-26 06:20:45.000000000 +0530 +++ libmpdclient-2.3/src/song.c 2010-07-25 22:50:35.000000000 +0530 @@ -35,10 +35,12 @@ #include #include "internal.h" #include "iso8601.h" +#include "uri.h" #include #include #include +#include struct mpd_tag_value { struct mpd_tag_value *next; @@ -57,6 +59,19 @@ unsigned duration; /** + * Start of the virtual song within the physical file in + * seconds. + */ + unsigned start; + + /** + * End of the virtual song within the physical file in + * seconds. Zero means that the physical song file is + * played to the end. + */ + unsigned end; + + /** * The POSIX UTC time stamp of the last modification, or 0 if * that is unknown. */ @@ -88,6 +103,7 @@ struct mpd_song *song; assert(uri != NULL); + assert(mpd_verify_uri(uri)); song = malloc(sizeof(*song)); if (song == NULL) @@ -104,6 +120,8 @@ song->tags[i].value = NULL; song->duration = 0; + song->start = 0; + song->end = 0; song->last_modified = 0; song->pos = 0; song->id = 0; @@ -178,6 +196,8 @@ } ret->duration = song->duration; + ret->start = song->start; + ret->end = song->end; ret->last_modified = song->last_modified; ret->pos = song->pos; ret->id = song->id; @@ -298,6 +318,18 @@ return song->duration; } +unsigned +mpd_song_get_start(const struct mpd_song *song) +{ + return song->start; +} + +unsigned +mpd_song_get_end(const struct mpd_song *song) +{ + return song->end; +} + static void mpd_song_set_last_modified(struct mpd_song *song, time_t mtime) { @@ -341,12 +373,46 @@ assert(pair->name != NULL); assert(pair->value != NULL); - if (strcmp(pair->name, "file") != 0) + if (strcmp(pair->name, "file") != 0 || !mpd_verify_uri(pair->value)) { + errno = EINVAL; return NULL; + } return mpd_song_new(pair->value); } +static void +mpd_song_parse_range(struct mpd_song *song, const char *value) +{ + assert(song != NULL); + assert(value != NULL); + + char *endptr; + double start, end; + + if (*value == '-') { + start = 0.0; + end = strtod(value + 1, NULL); + } else { + start = strtod(value, &endptr); + if (*endptr != '-') + return; + + end = strtod(endptr + 1, NULL); + } + + song->start = start > 0.0 ? (unsigned)start : 0; + + if (end > 0.0) { + song->end = (unsigned)end; + if (song->end == 0) + /* round up, because the caller must sees that + there's an upper limit */ + song->end = 1; + } else + song->end = 0; +} + bool mpd_song_feed(struct mpd_song *song, const struct mpd_pair *pair) { @@ -376,6 +442,8 @@ if (strcmp(pair->name, "Time") == 0) mpd_song_set_duration(song, atoi(pair->value)); + else if (strcmp(pair->name, "Range") == 0) + mpd_song_parse_range(song, pair->value); else if (strcmp(pair->name, "Last-Modified") == 0) mpd_song_set_last_modified(song, iso8601_datetime_parse(pair->value)); else if (strcmp(pair->name, "Pos") == 0) @@ -399,7 +467,7 @@ song = mpd_song_begin(pair); mpd_return_pair(connection, pair); if (song == NULL) { - mpd_error_code(&connection->error, MPD_ERROR_OOM); + mpd_error_entity(&connection->error); return NULL; } diff -Nru libmpdclient-2.2/src/uri.h libmpdclient-2.3/src/uri.h --- libmpdclient-2.2/src/uri.h 1970-01-01 05:30:00.000000000 +0530 +++ libmpdclient-2.3/src/uri.h 2010-07-25 22:50:35.000000000 +0530 @@ -0,0 +1,52 @@ +/* libmpdclient + (c) 2003-2010 The Music Player Daemon Project + This project's homepage is: http://www.musicpd.org + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef MPD_URI_H +#define MPD_URI_H + +#include +#include + +static inline bool +mpd_verify_uri(const char *uri) +{ + assert(uri != NULL); + + return *uri != 0; +} + +static inline bool +mpd_verify_local_uri(const char *uri) +{ + assert(uri != NULL); + + return mpd_verify_uri(uri) && *uri != '/' && + uri[strlen(uri) - 1] != '/'; +} + +#endif