From 6823217697043e3ad2c1e67e4bba759c66d18a4f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Feb 2009 16:44:06 +0100 Subject: 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. --- Makefile.am | 2 ++ src/command.c | 1 + src/decoder/vorbis_plugin.c | 2 +- src/decoder_thread.c | 2 +- src/ls.c | 14 +------------- src/ls.h | 8 -------- src/playlist_edit.c | 2 +- src/playlist_save.c | 2 +- src/queue_save.c | 2 +- src/song.c | 2 +- src/stored_playlist.c | 2 +- src/update.c | 2 +- src/uri.c | 37 +++++++++++++++++++++++++++++++++++++ src/uri.h | 33 +++++++++++++++++++++++++++++++++ 14 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 src/uri.c create mode 100644 src/uri.h diff --git a/Makefile.am b/Makefile.am index 689431777..0123cfa77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,6 +143,7 @@ mpd_headers = \ src/tag_print.h \ src/tag_save.h \ src/strset.h \ + src/uri.h \ src/utils.h \ src/volume.h \ src/zeroconf.h src/zeroconf-internal.h \ @@ -236,6 +237,7 @@ src_mpd_SOURCES = \ src/tag_print.c \ src/tag_save.c \ src/strset.c \ + src/uri.c \ src/utils.c \ src/volume.c \ src/locate.c \ diff --git a/src/command.c b/src/command.c index 42ea87f77..12094bfbf 100644 --- a/src/command.c +++ b/src/command.c @@ -23,6 +23,7 @@ #include "playlist_save.h" #include "queue_print.h" #include "ls.h" +#include "uri.h" #include "directory.h" #include "directory_print.h" #include "database.h" diff --git a/src/decoder/vorbis_plugin.c b/src/decoder/vorbis_plugin.c index 982165783..5d1611c97 100644 --- a/src/decoder/vorbis_plugin.c +++ b/src/decoder/vorbis_plugin.c @@ -20,7 +20,7 @@ #include "_ogg_common.h" #include "config.h" -#include "ls.h" +#include "uri.h" #ifndef HAVE_TREMOR #include diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 5aa13efc0..b35683e6e 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -30,7 +30,7 @@ #include "mapper.h" #include "path.h" #include "log.h" -#include "ls.h" +#include "uri.h" #include diff --git a/src/ls.c b/src/ls.c index 838680f60..a4d0f2f7e 100644 --- a/src/ls.c +++ b/src/ls.c @@ -17,6 +17,7 @@ */ #include "ls.h" +#include "uri.h" #include "client.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) { const char **urlPrefixes = remoteUrlPrefixes; @@ -65,11 +61,3 @@ bool uri_supported_scheme(const char *uri) 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; -} diff --git a/src/ls.h b/src/ls.h index 82a77ec17..d6e4c98b3 100644 --- a/src/ls.h +++ b/src/ls.h @@ -23,12 +23,6 @@ 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. * 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); -const char *uri_get_suffix(const char *utf8file); - #endif diff --git a/src/playlist_edit.c b/src/playlist_edit.c index 576cc8780..f4ebe3f7d 100644 --- a/src/playlist_edit.c +++ b/src/playlist_edit.c @@ -25,7 +25,7 @@ #include "playlist_internal.h" #include "player_control.h" #include "database.h" -#include "ls.h" +#include "uri.h" #include "song.h" #include "idle.h" diff --git a/src/playlist_save.c b/src/playlist_save.c index 65cc75e2f..e85305a93 100644 --- a/src/playlist_save.c +++ b/src/playlist_save.c @@ -21,7 +21,7 @@ #include "song.h" #include "mapper.h" #include "path.h" -#include "ls.h" +#include "uri.h" #include "database.h" #include "idle.h" diff --git a/src/queue_save.c b/src/queue_save.c index 73b59277d..b7aad6de2 100644 --- a/src/queue_save.c +++ b/src/queue_save.c @@ -19,7 +19,7 @@ #include "queue_save.h" #include "queue.h" #include "song.h" -#include "ls.h" +#include "uri.h" #include "database.h" #include diff --git a/src/song.c b/src/song.c index 6ddf597b2..0262d4b1a 100644 --- a/src/song.c +++ b/src/song.c @@ -17,7 +17,7 @@ */ #include "song.h" -#include "ls.h" +#include "uri.h" #include "directory.h" #include "mapper.h" #include "decoder_list.h" diff --git a/src/stored_playlist.c b/src/stored_playlist.c index ca2951b5e..c12821725 100644 --- a/src/stored_playlist.c +++ b/src/stored_playlist.c @@ -21,7 +21,7 @@ #include "song.h" #include "mapper.h" #include "path.h" -#include "ls.h" +#include "uri.h" #include "database.h" #include "idle.h" #include "conf.h" diff --git a/src/update.c b/src/update.c index 17059ffe0..66a41e49b 100644 --- a/src/update.c +++ b/src/update.c @@ -21,7 +21,7 @@ #include "database.h" #include "directory.h" #include "song.h" -#include "ls.h" +#include "uri.h" #include "mapper.h" #include "path.h" #include "decoder_list.h" diff --git a/src/uri.c b/src/uri.c new file mode 100644 index 000000000..6a6ddf82f --- /dev/null +++ b/src/uri.c @@ -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 + +#include + +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; +} diff --git a/src/uri.h b/src/uri.h new file mode 100644 index 000000000..6a20e94a4 --- /dev/null +++ b/src/uri.h @@ -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 + +/** + * 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 -- cgit v1.2.3