input/curl: rename struct input_curl to CurlInputStream

This commit is contained in:
Max Kellermann 2014-03-15 20:38:08 +01:00
parent f68d2f7c7f
commit 3d30de91f3
1 changed files with 32 additions and 32 deletions

View File

@ -130,7 +130,7 @@ public:
} }
}; };
struct input_curl { struct CurlInputStream {
InputStream base; InputStream base;
/* some buffers which were passed to libcurl, which we have /* some buffers which were passed to libcurl, which we have
@ -167,16 +167,16 @@ struct input_curl {
Error postponed_error; Error postponed_error;
input_curl(const char *url, Mutex &mutex, Cond &cond) CurlInputStream(const char *url, Mutex &mutex, Cond &cond)
:base(input_plugin_curl, url, mutex, cond), :base(input_plugin_curl, url, mutex, cond),
request_headers(nullptr), request_headers(nullptr),
paused(false), paused(false),
tag(nullptr) {} tag(nullptr) {}
~input_curl(); ~CurlInputStream();
input_curl(const input_curl &) = delete; CurlInputStream(const CurlInputStream &) = delete;
input_curl &operator=(const input_curl &) = delete; CurlInputStream &operator=(const CurlInputStream &) = delete;
}; };
class CurlMulti; class CurlMulti;
@ -251,8 +251,8 @@ public:
curl_multi_cleanup(multi); curl_multi_cleanup(multi);
} }
bool Add(input_curl *c, Error &error); bool Add(CurlInputStream *c, Error &error);
void Remove(input_curl *c); void Remove(CurlInputStream *c);
/** /**
* Check for finished HTTP responses. * Check for finished HTTP responses.
@ -322,7 +322,7 @@ CurlMulti::CurlMulti(EventLoop &_loop, CURLM *_multi)
* Runs in the I/O thread. No lock needed. * Runs in the I/O thread. No lock needed.
*/ */
gcc_pure gcc_pure
static struct input_curl * static CurlInputStream *
input_curl_find_request(CURL *easy) input_curl_find_request(CURL *easy)
{ {
assert(io_thread_inside()); assert(io_thread_inside());
@ -332,11 +332,11 @@ input_curl_find_request(CURL *easy)
if (code != CURLE_OK) if (code != CURLE_OK)
return nullptr; return nullptr;
return (input_curl *)p; return (CurlInputStream *)p;
} }
static void static void
input_curl_resume(struct input_curl *c) input_curl_resume(CurlInputStream *c)
{ {
assert(io_thread_inside()); assert(io_thread_inside());
@ -404,7 +404,7 @@ CurlSocket::OnSocketReady(unsigned flags)
* Runs in the I/O thread. No lock needed. * Runs in the I/O thread. No lock needed.
*/ */
inline bool inline bool
CurlMulti::Add(struct input_curl *c, Error &error) CurlMulti::Add(CurlInputStream *c, Error &error)
{ {
assert(io_thread_inside()); assert(io_thread_inside());
assert(c != nullptr); assert(c != nullptr);
@ -427,7 +427,7 @@ CurlMulti::Add(struct input_curl *c, Error &error)
* any thread. Caller must not hold a mutex. * any thread. Caller must not hold a mutex.
*/ */
static bool static bool
input_curl_easy_add_indirect(struct input_curl *c, Error &error) input_curl_easy_add_indirect(CurlInputStream *c, Error &error)
{ {
assert(c != nullptr); assert(c != nullptr);
assert(c->easy != nullptr); assert(c->easy != nullptr);
@ -440,7 +440,7 @@ input_curl_easy_add_indirect(struct input_curl *c, Error &error)
} }
inline void inline void
CurlMulti::Remove(input_curl *c) CurlMulti::Remove(CurlInputStream *c)
{ {
curl_multi_remove_handle(multi, c->easy); curl_multi_remove_handle(multi, c->easy);
} }
@ -452,7 +452,7 @@ CurlMulti::Remove(input_curl *c)
* Runs in the I/O thread. * Runs in the I/O thread.
*/ */
static void static void
input_curl_easy_free(struct input_curl *c) input_curl_easy_free(CurlInputStream *c)
{ {
assert(io_thread_inside()); assert(io_thread_inside());
assert(c != nullptr); assert(c != nullptr);
@ -476,7 +476,7 @@ input_curl_easy_free(struct input_curl *c)
* The mutex must not be locked. * The mutex must not be locked.
*/ */
static void static void
input_curl_easy_free_indirect(struct input_curl *c) input_curl_easy_free_indirect(CurlInputStream *c)
{ {
BlockingCall(io_thread_get(), [c](){ BlockingCall(io_thread_get(), [c](){
input_curl_easy_free(c); input_curl_easy_free(c);
@ -492,7 +492,7 @@ input_curl_easy_free_indirect(struct input_curl *c)
* Runs in the I/O thread. The caller must not hold locks. * Runs in the I/O thread. The caller must not hold locks.
*/ */
static void static void
input_curl_request_done(struct input_curl *c, CURLcode result, long status) input_curl_request_done(CurlInputStream *c, CURLcode result, long status)
{ {
assert(io_thread_inside()); assert(io_thread_inside());
assert(c != nullptr); assert(c != nullptr);
@ -518,7 +518,7 @@ input_curl_request_done(struct input_curl *c, CURLcode result, long status)
static void static void
input_curl_handle_done(CURL *easy_handle, CURLcode result) input_curl_handle_done(CURL *easy_handle, CURLcode result)
{ {
struct input_curl *c = input_curl_find_request(easy_handle); CurlInputStream *c = input_curl_find_request(easy_handle);
assert(c != nullptr); assert(c != nullptr);
long status = 0; long status = 0;
@ -664,7 +664,7 @@ input_curl_finish(void)
*/ */
gcc_pure gcc_pure
static size_t static size_t
curl_total_buffer_size(const struct input_curl *c) curl_total_buffer_size(const CurlInputStream *c)
{ {
size_t total = 0; size_t total = 0;
@ -674,7 +674,7 @@ curl_total_buffer_size(const struct input_curl *c)
return total; return total;
} }
input_curl::~input_curl() CurlInputStream::~CurlInputStream()
{ {
delete tag; delete tag;
@ -684,7 +684,7 @@ input_curl::~input_curl()
static bool static bool
input_curl_check(InputStream *is, Error &error) input_curl_check(InputStream *is, Error &error)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
bool success = !c->postponed_error.IsDefined(); bool success = !c->postponed_error.IsDefined();
if (!success) { if (!success) {
@ -698,7 +698,7 @@ input_curl_check(InputStream *is, Error &error)
static Tag * static Tag *
input_curl_tag(InputStream *is) input_curl_tag(InputStream *is)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
Tag *tag = c->tag; Tag *tag = c->tag;
c->tag = nullptr; c->tag = nullptr;
@ -706,7 +706,7 @@ input_curl_tag(InputStream *is)
} }
static bool static bool
fill_buffer(struct input_curl *c, Error &error) fill_buffer(CurlInputStream *c, Error &error)
{ {
while (c->easy != nullptr && c->buffers.empty()) while (c->easy != nullptr && c->buffers.empty())
c->base.cond.wait(c->base.mutex); c->base.cond.wait(c->base.mutex);
@ -771,7 +771,7 @@ read_from_buffer(IcyMetaDataParser &icy, std::list<CurlInputBuffer> &buffers,
} }
static void static void
copy_icy_tag(struct input_curl *c) copy_icy_tag(CurlInputStream *c)
{ {
Tag *tag = c->icy.ReadTag(); Tag *tag = c->icy.ReadTag();
@ -792,7 +792,7 @@ copy_icy_tag(struct input_curl *c)
static bool static bool
input_curl_available(InputStream *is) input_curl_available(InputStream *is)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
return c->postponed_error.IsDefined() || c->easy == nullptr || return c->postponed_error.IsDefined() || c->easy == nullptr ||
!c->buffers.empty(); !c->buffers.empty();
@ -802,7 +802,7 @@ static size_t
input_curl_read(InputStream *is, void *ptr, size_t size, input_curl_read(InputStream *is, void *ptr, size_t size,
Error &error) Error &error)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
bool success; bool success;
size_t nbytes = 0; size_t nbytes = 0;
char *dest = (char *)ptr; char *dest = (char *)ptr;
@ -846,7 +846,7 @@ input_curl_read(InputStream *is, void *ptr, size_t size,
static void static void
input_curl_close(InputStream *is) input_curl_close(InputStream *is)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
delete c; delete c;
} }
@ -854,7 +854,7 @@ input_curl_close(InputStream *is)
static bool static bool
input_curl_eof(gcc_unused InputStream *is) input_curl_eof(gcc_unused InputStream *is)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
return c->easy == nullptr && c->buffers.empty(); return c->easy == nullptr && c->buffers.empty();
} }
@ -863,7 +863,7 @@ input_curl_eof(gcc_unused InputStream *is)
static size_t static size_t
input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream) input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
struct input_curl *c = (struct input_curl *)stream; CurlInputStream *c = (CurlInputStream *)stream;
char name[64]; char name[64];
size *= nmemb; size *= nmemb;
@ -947,7 +947,7 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
static size_t static size_t
input_curl_writefunction(void *ptr, size_t size, size_t nmemb, void *stream) input_curl_writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
struct input_curl *c = (struct input_curl *)stream; CurlInputStream *c = (CurlInputStream *)stream;
size *= nmemb; size *= nmemb;
if (size == 0) if (size == 0)
@ -968,7 +968,7 @@ input_curl_writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
} }
static bool static bool
input_curl_easy_init(struct input_curl *c, Error &error) input_curl_easy_init(CurlInputStream *c, Error &error)
{ {
CURLcode code; CURLcode code;
@ -1032,7 +1032,7 @@ input_curl_seek(InputStream *is, InputPlugin::offset_type offset,
int whence, int whence,
Error &error) Error &error)
{ {
struct input_curl *c = (struct input_curl *)is; CurlInputStream *c = (CurlInputStream *)is;
bool ret; bool ret;
assert(is->ready); assert(is->ready);
@ -1140,7 +1140,7 @@ input_curl_open(const char *url, Mutex &mutex, Cond &cond,
memcmp(url, "https://", 8) != 0) memcmp(url, "https://", 8) != 0)
return nullptr; return nullptr;
struct input_curl *c = new input_curl(url, mutex, cond); CurlInputStream *c = new CurlInputStream(url, mutex, cond);
if (!input_curl_easy_init(c, error)) { if (!input_curl_easy_init(c, error)) {
delete c; delete c;