aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/url.h
diff options
context:
space:
mode:
authorNicolas George <george@nsup.org>2020-07-29 14:39:20 +0200
committerNicolas George <george@nsup.org>2020-08-12 16:33:09 +0200
commitd853293679f93ef882e6a5f1c47eb5a65ceddf3d (patch)
treea98280626780bd89a6d3294558667ed2bc617a27 /libavformat/url.h
parent64ff61b3c52af335e811fe04b85108775e1f2784 (diff)
downloadffmpeg-d853293679f93ef882e6a5f1c47eb5a65ceddf3d.tar.gz
lavf/url: add ff_url_decompose().
Diffstat (limited to 'libavformat/url.h')
-rw-r--r--libavformat/url.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/libavformat/url.h b/libavformat/url.h
index de0d30aca0..ae27da5c73 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -344,4 +344,45 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter);
const URLProtocol **ffurl_get_protocols(const char *whitelist,
const char *blacklist);
+typedef struct URLComponents {
+ const char *url; /**< whole URL, for reference */
+ const char *scheme; /**< possibly including lavf-specific options */
+ const char *authority; /**< "//" if it is a real URL */
+ const char *userinfo; /**< including final '@' if present */
+ const char *host;
+ const char *port; /**< including initial ':' if present */
+ const char *path;
+ const char *query; /**< including initial '?' if present */
+ const char *fragment; /**< including initial '#' if present */
+ const char *end;
+} URLComponents;
+
+#define url_component_end_scheme authority
+#define url_component_end_authority userinfo
+#define url_component_end_userinfo host
+#define url_component_end_host port
+#define url_component_end_port path
+#define url_component_end_path query
+#define url_component_end_query fragment
+#define url_component_end_fragment end
+#define url_component_end_authority_full path
+
+#define URL_COMPONENT_HAVE(uc, component) \
+ ((uc).url_component_end_##component > (uc).component)
+
+/**
+ * Parse an URL to find the components.
+ *
+ * Each component runs until the start of the next component,
+ * possibly including a mandatory delimiter.
+ *
+ * @param uc structure to fill with pointers to the components.
+ * @param url URL to parse.
+ * @param end end of the URL, or NULL to parse to the end of string.
+ *
+ * @return >= 0 for success or an AVERROR code, especially if the URL is
+ * malformed.
+ */
+int ff_url_decompose(URLComponents *uc, const char *url, const char *end);
+
#endif /* AVFORMAT_URL_H */