2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ls.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#include "path.h"
|
2008-09-07 14:02:40 +02:00
|
|
|
#include "client.h"
|
2004-02-24 00:41:20 +01:00
|
|
|
#include "log.h"
|
2008-09-26 09:54:25 +02:00
|
|
|
#include "list.h"
|
2008-10-22 19:15:50 +02:00
|
|
|
#include "stored_playlist.h"
|
2008-01-03 08:29:49 +01:00
|
|
|
#include "os_compat.h"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-02-05 11:17:33 +01:00
|
|
|
static const char *remoteUrlPrefixes[] = {
|
2008-10-26 19:32:43 +01:00
|
|
|
#ifdef HAVE_CURL
|
2006-07-20 18:02:40 +02:00
|
|
|
"http://",
|
2008-10-26 19:32:43 +01:00
|
|
|
#endif
|
2004-06-02 03:26:15 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-12-16 21:18:31 +01:00
|
|
|
void printRemoteUrlHandlers(struct client *client)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2008-02-05 11:17:33 +01:00
|
|
|
const char **prefixes = remoteUrlPrefixes;
|
2004-06-03 01:22:37 +02:00
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
while (*prefixes) {
|
2008-09-07 14:02:40 +02:00
|
|
|
client_printf(client, "handler: %s\n", *prefixes);
|
2006-07-20 18:02:40 +02:00
|
|
|
prefixes++;
|
|
|
|
}
|
2004-06-03 01:22:37 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 21:18:33 +01:00
|
|
|
|
|
|
|
bool isRemoteUrl(const char *url)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2008-02-05 11:17:33 +01:00
|
|
|
const char **urlPrefixes = remoteUrlPrefixes;
|
2004-05-14 23:35:20 +02:00
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
while (*urlPrefixes) {
|
2008-10-28 20:33:56 +01:00
|
|
|
if (g_str_has_prefix(url, *urlPrefixes))
|
2008-12-16 21:18:33 +01:00
|
|
|
return true;
|
2004-05-14 23:35:20 +02:00
|
|
|
urlPrefixes++;
|
2004-05-13 20:46:38 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 21:18:33 +01:00
|
|
|
return false;
|
2004-05-13 20:46:38 +02:00
|
|
|
}
|
|
|
|
|
2004-05-30 02:05:23 +02:00
|
|
|
/* suffixes should be ascii only characters */
|
2008-02-05 11:17:33 +01:00
|
|
|
const char *getSuffix(const char *utf8file)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2008-12-16 21:20:09 +01:00
|
|
|
const char *dot = strrchr(utf8file, '.');
|
2006-07-14 21:02:48 +02:00
|
|
|
|
2008-12-16 21:20:09 +01:00
|
|
|
return dot != NULL ? dot + 1 : NULL;
|
2004-03-21 04:45:58 +01:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-11-01 14:51:41 +01:00
|
|
|
const struct decoder_plugin *
|
|
|
|
hasMusicSuffix(const char *utf8file, unsigned int next)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2008-11-01 14:51:41 +01:00
|
|
|
const struct decoder_plugin *ret = NULL;
|
2006-07-20 18:02:40 +02:00
|
|
|
|
2008-02-05 11:17:33 +01:00
|
|
|
const char *s = getSuffix(utf8file);
|
2006-07-20 18:02:40 +02:00
|
|
|
if (s) {
|
2008-08-26 08:27:09 +02:00
|
|
|
ret = decoder_plugin_from_suffix(s, next);
|
2006-07-20 18:02:40 +02:00
|
|
|
} else {
|
|
|
|
DEBUG("hasMusicSuffix: The file: %s has no valid suffix\n",
|
|
|
|
utf8file);
|
2005-09-08 23:08:02 +02:00
|
|
|
}
|
2004-03-21 04:45:58 +01:00
|
|
|
|
2004-05-31 03:21:17 +02:00
|
|
|
return ret;
|
2004-03-21 04:45:58 +01:00
|
|
|
}
|