ls: moved generic URI utilities to uri.c
"ls" is a bad name for a library which parses URIs. We'll move the rest of the "ls" library later.
This commit is contained in:
parent
7957fefc91
commit
6823217697
@ -143,6 +143,7 @@ mpd_headers = \
|
|||||||
src/tag_print.h \
|
src/tag_print.h \
|
||||||
src/tag_save.h \
|
src/tag_save.h \
|
||||||
src/strset.h \
|
src/strset.h \
|
||||||
|
src/uri.h \
|
||||||
src/utils.h \
|
src/utils.h \
|
||||||
src/volume.h \
|
src/volume.h \
|
||||||
src/zeroconf.h src/zeroconf-internal.h \
|
src/zeroconf.h src/zeroconf-internal.h \
|
||||||
@ -236,6 +237,7 @@ src_mpd_SOURCES = \
|
|||||||
src/tag_print.c \
|
src/tag_print.c \
|
||||||
src/tag_save.c \
|
src/tag_save.c \
|
||||||
src/strset.c \
|
src/strset.c \
|
||||||
|
src/uri.c \
|
||||||
src/utils.c \
|
src/utils.c \
|
||||||
src/volume.c \
|
src/volume.c \
|
||||||
src/locate.c \
|
src/locate.c \
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "playlist_save.h"
|
#include "playlist_save.h"
|
||||||
#include "queue_print.h"
|
#include "queue_print.h"
|
||||||
#include "ls.h"
|
#include "ls.h"
|
||||||
|
#include "uri.h"
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "directory_print.h"
|
#include "directory_print.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "_ogg_common.h"
|
#include "_ogg_common.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
|
|
||||||
#ifndef HAVE_TREMOR
|
#ifndef HAVE_TREMOR
|
||||||
#include <vorbis/vorbisfile.h>
|
#include <vorbis/vorbisfile.h>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
14
src/ls.c
14
src/ls.c
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ls.h"
|
#include "ls.h"
|
||||||
|
#include "uri.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@ -46,11 +47,6 @@ void print_supported_uri_schemes(struct client *client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uri_has_scheme(const char *uri)
|
|
||||||
{
|
|
||||||
return strstr(uri, "://") != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool uri_supported_scheme(const char *uri)
|
bool uri_supported_scheme(const char *uri)
|
||||||
{
|
{
|
||||||
const char **urlPrefixes = remoteUrlPrefixes;
|
const char **urlPrefixes = remoteUrlPrefixes;
|
||||||
@ -65,11 +61,3 @@ bool uri_supported_scheme(const char *uri)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* suffixes should be ascii only characters */
|
|
||||||
const char *uri_get_suffix(const char *utf8file)
|
|
||||||
{
|
|
||||||
const char *dot = strrchr(g_basename(utf8file), '.');
|
|
||||||
|
|
||||||
return dot != NULL ? dot + 1 : NULL;
|
|
||||||
}
|
|
||||||
|
8
src/ls.h
8
src/ls.h
@ -23,12 +23,6 @@
|
|||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the specified URI has a schema in the form
|
|
||||||
* "scheme://".
|
|
||||||
*/
|
|
||||||
bool uri_has_scheme(const char *uri);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the scheme of the specified URI is supported by MPD.
|
* Checks whether the scheme of the specified URI is supported by MPD.
|
||||||
* It is not allowed to pass an URI without a scheme, check with
|
* It is not allowed to pass an URI without a scheme, check with
|
||||||
@ -42,6 +36,4 @@ bool uri_supported_scheme(const char *url);
|
|||||||
*/
|
*/
|
||||||
void print_supported_uri_schemes(struct client *client);
|
void print_supported_uri_schemes(struct client *client);
|
||||||
|
|
||||||
const char *uri_get_suffix(const char *utf8file);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "playlist_internal.h"
|
#include "playlist_internal.h"
|
||||||
#include "player_control.h"
|
#include "player_control.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "queue_save.h"
|
#include "queue_save.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "decoder_list.h"
|
#include "decoder_list.h"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "ls.h"
|
#include "uri.h"
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "decoder_list.h"
|
#include "decoder_list.h"
|
||||||
|
37
src/uri.c
Normal file
37
src/uri.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2009 The Music Player Daemon Project
|
||||||
|
* 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 "uri.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
bool uri_has_scheme(const char *uri)
|
||||||
|
{
|
||||||
|
return strstr(uri, "://") != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* suffixes should be ascii only characters */
|
||||||
|
const char *
|
||||||
|
uri_get_suffix(const char *uri)
|
||||||
|
{
|
||||||
|
const char *dot = strrchr(g_basename(uri), '.');
|
||||||
|
|
||||||
|
return dot != NULL ? dot + 1 : NULL;
|
||||||
|
}
|
33
src/uri.h
Normal file
33
src/uri.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2009 The Music Player Daemon Project
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MPD_URI_H
|
||||||
|
#define MPD_URI_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the specified URI has a schema in the form
|
||||||
|
* "scheme://".
|
||||||
|
*/
|
||||||
|
bool uri_has_scheme(const char *uri);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
uri_get_suffix(const char *uri);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user