UriUtil: add function uri_get_scheme()
Replaces g_uri_parse_scheme().
This commit is contained in:
parent
65b8e52d80
commit
e1ec65bd53
@ -40,8 +40,6 @@
|
|||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -130,13 +128,12 @@ static SongEnumerator *
|
|||||||
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
||||||
bool *tried)
|
bool *tried)
|
||||||
{
|
{
|
||||||
char *scheme;
|
|
||||||
SongEnumerator *playlist = nullptr;
|
SongEnumerator *playlist = nullptr;
|
||||||
|
|
||||||
assert(uri != nullptr);
|
assert(uri != nullptr);
|
||||||
|
|
||||||
scheme = g_uri_parse_scheme(uri);
|
const auto scheme = uri_get_scheme(uri);
|
||||||
if (scheme == nullptr)
|
if (scheme.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
|
for (unsigned i = 0; playlist_plugins[i] != nullptr; ++i) {
|
||||||
@ -146,7 +143,7 @@ playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
|||||||
|
|
||||||
if (playlist_plugins_enabled[i] && plugin->open_uri != nullptr &&
|
if (playlist_plugins_enabled[i] && plugin->open_uri != nullptr &&
|
||||||
plugin->schemes != nullptr &&
|
plugin->schemes != nullptr &&
|
||||||
string_array_contains(plugin->schemes, scheme)) {
|
string_array_contains(plugin->schemes, scheme.c_str())) {
|
||||||
playlist = playlist_plugin_open_uri(plugin, uri,
|
playlist = playlist_plugin_open_uri(plugin, uri,
|
||||||
mutex, cond);
|
mutex, cond);
|
||||||
if (playlist != nullptr)
|
if (playlist != nullptr)
|
||||||
@ -156,7 +153,6 @@ playlist_list_open_uri_scheme(const char *uri, Mutex &mutex, Cond &cond,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(scheme);
|
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,16 @@ bool uri_has_scheme(const char *uri)
|
|||||||
return strstr(uri, "://") != nullptr;
|
return strstr(uri, "://") != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
uri_get_scheme(const char *uri)
|
||||||
|
{
|
||||||
|
const char *end = strstr(uri, "://");
|
||||||
|
if (end == nullptr)
|
||||||
|
end = uri;
|
||||||
|
|
||||||
|
return std::string(uri, end);
|
||||||
|
}
|
||||||
|
|
||||||
/* suffixes should be ascii only characters */
|
/* suffixes should be ascii only characters */
|
||||||
const char *
|
const char *
|
||||||
uri_get_suffix(const char *uri)
|
uri_get_suffix(const char *uri)
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
gcc_pure
|
gcc_pure
|
||||||
bool uri_has_scheme(const char *uri);
|
bool uri_has_scheme(const char *uri);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the scheme name of the specified URI, or an empty string.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
std::string
|
||||||
|
uri_get_scheme(const char *uri);
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const char *
|
const char *
|
||||||
uri_get_suffix(const char *uri);
|
uri_get_suffix(const char *uri);
|
||||||
|
Loading…
Reference in New Issue
Block a user