aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-03-15 22:56:05 +0100
committerMax Kellermann <max@duempel.org>2014-03-15 22:56:05 +0100
commit8f74bf314d706abbe25a8dd23a6465c0227ffc71 (patch)
treeae07482c8336339937d88576b05ea2f89525ca74 /src/input/plugins
parent0dd5ebbdbeb79481c4a074908c41acba79d05bd6 (diff)
downloadmpd-8f74bf314d706abbe25a8dd23a6465c0227ffc71.tar.gz
mpd-8f74bf314d706abbe25a8dd23a6465c0227ffc71.tar.xz
mpd-8f74bf314d706abbe25a8dd23a6465c0227ffc71.zip
input/curl: add method CurlInputStream::Open()
Diffstat (limited to 'src/input/plugins')
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index 9d9adcf07..60facb26b 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -178,6 +178,9 @@ struct CurlInputStream {
CurlInputStream(const CurlInputStream &) = delete;
CurlInputStream &operator=(const CurlInputStream &) = delete;
+ static InputStream *Open(const char *url, Mutex &mutex, Cond &cond,
+ Error &error);
+
bool Check(Error &error);
bool IsEOF() const {
@@ -1174,27 +1177,29 @@ input_curl_seek(InputStream *is, InputPlugin::offset_type offset,
return c.Seek(offset, whence, error);
}
-static InputStream *
-input_curl_open(const char *url, Mutex &mutex, Cond &cond,
- Error &error)
+inline InputStream *
+CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond,
+ Error &error)
{
- if (memcmp(url, "http://", 7) != 0 &&
- memcmp(url, "https://", 8) != 0)
- return nullptr;
-
CurlInputStream *c = new CurlInputStream(url, mutex, cond);
- if (!c->InitEasy(error)) {
+ if (!c->InitEasy(error) || !input_curl_easy_add_indirect(c, error)) {
delete c;
return nullptr;
}
- if (!input_curl_easy_add_indirect(c, error)) {
- delete c;
+ return &c->base;
+}
+
+static InputStream *
+input_curl_open(const char *url, Mutex &mutex, Cond &cond,
+ Error &error)
+{
+ if (memcmp(url, "http://", 7) != 0 &&
+ memcmp(url, "https://", 8) != 0)
return nullptr;
- }
- return &c->base;
+ return CurlInputStream::Open(url, mutex, cond, error);
}
const struct InputPlugin input_plugin_curl = {