#endif
#include "url.h"
-static URLProtocol *first_protocol = NULL;
-
-URLProtocol *ffurl_protocol_next(const URLProtocol *prev)
-{
- return prev ? prev->next : first_protocol;
-}
-
/** @name Logging context. */
/*@{*/
static const char *urlcontext_to_name(void *ptr)
static const AVClass *urlcontext_child_class_next(const AVClass *prev)
{
- URLProtocol *p = NULL;
+ int i;
/* find the protocol that corresponds to prev */
- while (prev && (p = ffurl_protocol_next(p)))
- if (p->priv_data_class == prev)
+ for (i = 0; ff_url_protocols[i]; i++) {
+ if (ff_url_protocols[i]->priv_data_class == prev) {
+ i++;
break;
+ }
+ }
/* find next protocol with priv options */
- while (p = ffurl_protocol_next(p))
- if (p->priv_data_class)
- return p->priv_data_class;
+ for (; ff_url_protocols[i]; i++)
+ if (ff_url_protocols[i]->priv_data_class)
+ return ff_url_protocols[i]->priv_data_class;
return NULL;
}
};
/*@}*/
-const char *avio_enum_protocols(void **opaque, int output)
-{
- URLProtocol *p;
- *opaque = ffurl_protocol_next(*opaque);
- if (!(p = *opaque))
- return NULL;
- if ((output && p->url_write) || (!output && p->url_read))
- return p->name;
- return avio_enum_protocols(opaque, output);
-}
-
-int ffurl_register_protocol(URLProtocol *protocol)
-{
- URLProtocol **p;
- p = &first_protocol;
- while (*p)
- p = &(*p)->next;
- *p = protocol;
- protocol->next = NULL;
- return 0;
-}
-
-static int url_alloc_for_protocol(URLContext **puc, struct URLProtocol *up,
+static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
const char *filename, int flags,
const AVIOInterruptCB *int_cb)
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"0123456789+-."
-static struct URLProtocol *url_find_protocol(const char *filename)
+static const struct URLProtocol *url_find_protocol(const char *filename)
{
- URLProtocol *up = NULL;
+ const URLProtocol *up;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
+ int i;
if (filename[proto_len] != ':' &&
(strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';
- while (up = ffurl_protocol_next(up)) {
+ for (i = 0; ff_url_protocols[i]; i++) {
+ up = ff_url_protocols[i];
if (!strcmp(proto_str, up->name))
break;
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
int ffurl_alloc(URLContext **puc, const char *filename, int flags,
const AVIOInterruptCB *int_cb)
{
- URLProtocol *p = NULL;
-
- if (!first_protocol) {
- av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
- "Missing call to av_register_all()?\n");
- }
+ const URLProtocol *p = NULL;
p = url_find_protocol(filename);
if (p)
const char *avio_find_protocol_name(const char *url)
{
- URLProtocol *p = url_find_protocol(url);
+ const URLProtocol *p = url_find_protocol(url);
return p ? p->name : NULL;
}