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"
|
2006-08-26 08:25:57 +02:00
|
|
|
#include "utils.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[] = {
|
2006-07-20 18:02:40 +02:00
|
|
|
"http://",
|
2004-06-02 03:26:15 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-09-07 14:02:40 +02:00
|
|
|
int 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
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
return 0;
|
2004-06-03 01:22:37 +02:00
|
|
|
}
|
|
|
|
|
2008-08-29 09:01:53 +02:00
|
|
|
int isValidRemoteUtf8Url(const char *utf8url)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2008-08-29 09:01:53 +02:00
|
|
|
const char *temp;
|
2006-07-20 18:02:40 +02:00
|
|
|
|
|
|
|
switch (isRemoteUrl(utf8url)) {
|
|
|
|
case 1:
|
|
|
|
ret = 1;
|
|
|
|
temp = utf8url;
|
|
|
|
while (*temp) {
|
|
|
|
if ((*temp >= 'a' && *temp <= 'z') ||
|
|
|
|
(*temp >= 'A' && *temp <= 'Z') ||
|
|
|
|
(*temp >= '0' && *temp <= '9') ||
|
|
|
|
*temp == '$' ||
|
|
|
|
*temp == '-' ||
|
|
|
|
*temp == '.' ||
|
|
|
|
*temp == '+' ||
|
|
|
|
*temp == '!' ||
|
|
|
|
*temp == '*' ||
|
|
|
|
*temp == '\'' ||
|
|
|
|
*temp == '(' ||
|
|
|
|
*temp == ')' ||
|
|
|
|
*temp == ',' ||
|
|
|
|
*temp == '%' ||
|
|
|
|
*temp == '/' ||
|
|
|
|
*temp == ':' ||
|
|
|
|
*temp == '?' ||
|
|
|
|
*temp == ';' || *temp == '&' || *temp == '=') {
|
|
|
|
} else {
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
temp++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2004-06-02 03:26:15 +02:00
|
|
|
}
|
|
|
|
|
2008-08-29 09:01:53 +02:00
|
|
|
int isRemoteUrl(const char *url)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
|
|
|
int count = 0;
|
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) {
|
|
|
|
count++;
|
2008-09-23 20:48:12 +02:00
|
|
|
if (!prefixcmp(url, *urlPrefixes))
|
2006-07-20 18:02:40 +02:00
|
|
|
return count;
|
2004-05-14 23:35:20 +02:00
|
|
|
urlPrefixes++;
|
2004-05-13 20:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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-02-05 11:17:33 +01:00
|
|
|
const char *ret = NULL;
|
2006-07-14 21:02:48 +02:00
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
while (*utf8file) {
|
|
|
|
if (*utf8file == '.')
|
|
|
|
ret = utf8file + 1;
|
|
|
|
utf8file++;
|
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-03-21 04:45:58 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-08-26 08:27:08 +02:00
|
|
|
struct decoder_plugin *hasMusicSuffix(const char *utf8file, unsigned int next)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2008-08-26 08:27:08 +02:00
|
|
|
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
|
|
|
}
|