From af4133e3c92c78cc19ff14b876be6afcab1db091 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Nov 2013 18:48:35 +0100 Subject: Util/StringUtil: add StringStartsWith() Replaces GLib's g_str_has_prefix(). --- src/input/CdioParanoiaInputPlugin.cxx | 3 ++- src/input/DespotifyInputPlugin.cxx | 5 ++--- src/input/FfmpegInputPlugin.cxx | 15 +++++++-------- src/input/MmsInputPlugin.cxx | 10 +++++----- 4 files changed, 16 insertions(+), 17 deletions(-) (limited to 'src/input') diff --git a/src/input/CdioParanoiaInputPlugin.cxx b/src/input/CdioParanoiaInputPlugin.cxx index cc366bff5..de699ea3a 100644 --- a/src/input/CdioParanoiaInputPlugin.cxx +++ b/src/input/CdioParanoiaInputPlugin.cxx @@ -25,6 +25,7 @@ #include "CdioParanoiaInputPlugin.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" +#include "util/StringUtil.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "system/ByteOrder.hxx" @@ -117,7 +118,7 @@ struct cdio_uri { static bool parse_cdio_uri(struct cdio_uri *dest, const char *src, Error &error) { - if (!g_str_has_prefix(src, "cdda://")) + if (!StringStartsWith(src, "cdda://")) return false; src += 7; diff --git a/src/input/DespotifyInputPlugin.cxx b/src/input/DespotifyInputPlugin.cxx index b08299516..9441ef327 100644 --- a/src/input/DespotifyInputPlugin.cxx +++ b/src/input/DespotifyInputPlugin.cxx @@ -23,14 +23,13 @@ #include "InputStream.hxx" #include "InputPlugin.hxx" #include "tag/Tag.hxx" +#include "util/StringUtil.hxx" #include "Log.hxx" extern "C" { #include } -#include - #include #include #include @@ -130,7 +129,7 @@ input_despotify_open(const char *url, struct ds_link *ds_link; struct ds_track *track; - if (!g_str_has_prefix(url, "spt://")) + if (!StringStartsWith(url, "spt://")) return nullptr; session = mpd_despotify_get_session(); diff --git a/src/input/FfmpegInputPlugin.cxx b/src/input/FfmpegInputPlugin.cxx index c6f4afb7f..7d041677b 100644 --- a/src/input/FfmpegInputPlugin.cxx +++ b/src/input/FfmpegInputPlugin.cxx @@ -24,6 +24,7 @@ #include "FfmpegInputPlugin.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" +#include "util/StringUtil.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" @@ -32,8 +33,6 @@ extern "C" { #include } -#include - struct FfmpegInputStream { InputStream base; @@ -90,12 +89,12 @@ input_ffmpeg_open(const char *uri, Mutex &mutex, Cond &cond, Error &error) { - if (!g_str_has_prefix(uri, "gopher://") && - !g_str_has_prefix(uri, "rtp://") && - !g_str_has_prefix(uri, "rtsp://") && - !g_str_has_prefix(uri, "rtmp://") && - !g_str_has_prefix(uri, "rtmpt://") && - !g_str_has_prefix(uri, "rtmps://")) + if (!StringStartsWith(uri, "gopher://") && + !StringStartsWith(uri, "rtp://") && + !StringStartsWith(uri, "rtsp://") && + !StringStartsWith(uri, "rtmp://") && + !StringStartsWith(uri, "rtmpt://") && + !StringStartsWith(uri, "rtmps://")) return nullptr; AVIOContext *h; diff --git a/src/input/MmsInputPlugin.cxx b/src/input/MmsInputPlugin.cxx index df45f71e8..2c7f6d166 100644 --- a/src/input/MmsInputPlugin.cxx +++ b/src/input/MmsInputPlugin.cxx @@ -21,10 +21,10 @@ #include "MmsInputPlugin.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" +#include "util/StringUtil.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" -#include #include struct MmsInputStream { @@ -58,10 +58,10 @@ input_mms_open(const char *url, Mutex &mutex, Cond &cond, Error &error) { - if (!g_str_has_prefix(url, "mms://") && - !g_str_has_prefix(url, "mmsh://") && - !g_str_has_prefix(url, "mmst://") && - !g_str_has_prefix(url, "mmsu://")) + if (!StringStartsWith(url, "mms://") && + !StringStartsWith(url, "mmsh://") && + !StringStartsWith(url, "mmst://") && + !StringStartsWith(url, "mmsu://")) return nullptr; const auto mms = mmsx_connect(nullptr, nullptr, url, 128 * 1024); -- cgit v1.2.3