41 const char *authorization,
const char *hostname,
42 int port,
const char *fmt, ...)
51 if (authorization && authorization[0])
53#if CONFIG_NETWORK && defined(AF_INET6)
58 if (ai->ai_family == AF_INET6) {
75 size_t len = strlen(str);
84static const char *
find_delim(
const char *delim,
const char *cur,
const char *end)
86 while (cur < end && !strchr(delim, *cur))
93 const char *cur, *aend, *p;
97 end = url + strlen(url);
108 if (end - cur >= 2 && cur[0] ==
'/' && cur[1] ==
'/') {
124 if (p + 1 < aend && p[1] !=
':')
156 if ((path[0] >=
'a' && path[0] <=
'z' || path[0] >=
'A' && path[0] <=
'Z') &&
158 (path[2] ==
'/' || path[2] ==
'\\'))
160 if ((path[0] ==
'/' || path[0] ==
'\\') &&
161 (path[1] ==
'/' || path[1] ==
'\\'))
167 const char *in,
const char *in_end)
170 const char *d, *next;
172 if (in < in_end && *in ==
'/')
174 while (in < in_end) {
176 next = d + (d < in_end && *d ==
'/');
177 if (d - in == 1 && in[0] ==
'.') {
179 }
else if (d - in == 2 && in[0] ==
'.' && in[1] ==
'.') {
182 while (
out > root && (--
out)[-1] !=
'/');
184 if (out_end -
out < next - in)
186 memmove(
out, in, next - in);
196 const char *rel,
int handle_dos_paths)
199 char *
out, *out_end, *path;
200 const char *keep, *base_path_end;
201 int use_base_path, simplify_path = 0, ret;
202 const char *base_separators =
"/";
225 out_end = buf +
size - 1;
229 if (handle_dos_paths) {
233 base_separators =
"/\\";
243#define KEEP(component, also) do { \
244 if (uc.url_component_end_##component == uc.url && \
245 ub.url_component_end_##component > keep) { \
246 keep = ub.url_component_end_##component; \
251 KEEP(authority_full, simplify_path = 1;);
256#define COPY(start, end) do { \
257 size_t len = end - start; \
258 if (len > out_end - out) { \
259 ret = AVERROR(ENOMEM); \
262 memmove(out, start, len); \
274 base_path_end =
ub.url_component_end_path;
276 while (base_path_end >
ub.path && !strchr(base_separators, base_path_end[-1]))
290 const char *root =
"/";
291 COPY(root, root + 1);
305 COPY(
ub.path, base_path_end);
306 COPY(uc.
path, uc.url_component_end_path);
309 COPY(uc.url_component_end_path, uc.
end);
316 ret ==
AVERROR(ENOMEM) ?
"truncated" :
317 ret ==
AVERROR(EINVAL) ?
"syntax_error" :
"");
333 entry->modification_timestamp = -1;
334 entry->access_timestamp = -1;
335 entry->status_change_timestamp = -1;
337 entry->group_id = -1;
338 entry->filemode = -1;
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Memory handling functions.
Describes single entry of the directory.
const char * scheme
possibly including lavf-specific options
const char * port
including initial ':' if present
const char * authority
"//" if it is a real URL
const char * fragment
including initial '#' if present
const char * userinfo
including final '@' if present
const char * query
including initial '?
const char * url
whole URL, for reference
static void error(const char *err)
int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
Parse an URL to find the components.
static int is_fq_dos_path(const char *path)
static int append_path(char *root, char *out_end, char **rout, const char *in, const char *in_end)
int ff_make_absolute_url2(char *buf, int size, const char *base, const char *rel, int handle_dos_paths)
Convert a relative url into an absolute url, given a base url.
int ff_make_absolute_url(char *buf, int size, const char *base, const char *rel)
Convert a relative url into an absolute url, given a base url.
static const char * find_delim(const char *delim, const char *cur, const char *end)
#define KEEP(component, also)
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
AVIODirEntry * ff_alloc_dir_entry(void)
Allocate directory entry with default values.
unbuffered private I/O API
#define URL_COMPONENT_HAVE(uc, component)