MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_url_split

Function av_url_split

libavformat/utils.c:361–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361void av_url_split(char *proto, int proto_size,
362 char *authorization, int authorization_size,
363 char *hostname, int hostname_size,
364 int *port_ptr, char *path, int path_size, const char *url)
365{
366 const char *p, *ls, *at, *at2, *col, *brk;
367
368 if (port_ptr)
369 *port_ptr = -1;
370 if (proto_size > 0)
371 proto[0] = 0;
372 if (authorization_size > 0)
373 authorization[0] = 0;
374 if (hostname_size > 0)
375 hostname[0] = 0;
376 if (path_size > 0)
377 path[0] = 0;
378
379 /* parse protocol */
380 if ((p = strchr(url, ':'))) {
381 av_strlcpy(proto, url, FFMIN(proto_size, p + 1 - url));
382 p++; /* skip ':' */
383 if (*p == '/')
384 p++;
385 if (*p == '/')
386 p++;
387 } else {
388 /* no protocol means plain filename */
389 av_strlcpy(path, url, path_size);
390 return;
391 }
392
393 /* separate path from hostname */
394 ls = p + strcspn(p, "/?#");
395 av_strlcpy(path, ls, path_size);
396
397 /* the rest is hostname, use that to parse auth/port */
398 if (ls != p) {
399 /* authorization (user[:pass]@hostname) */
400 at2 = p;
401 while ((at = strchr(p, '@')) && at < ls) {
402 av_strlcpy(authorization, at2,
403 FFMIN(authorization_size, at + 1 - at2));
404 p = at + 1; /* skip '@' */
405 }
406
407 if (*p == '[' && (brk = strchr(p, ']')) && brk < ls) {
408 /* [host]:port */
409 av_strlcpy(hostname, p + 1,
410 FFMIN(hostname_size, brk - p));
411 if (brk[1] == ':' && port_ptr)
412 *port_ptr = atoi(brk + 2);
413 } else if ((col = strchr(p, ':')) && col < ls) {
414 av_strlcpy(hostname, p,
415 FFMIN(col + 1 - p, hostname_size));
416 if (port_ptr)
417 *port_ptr = atoi(col + 1);
418 } else

Callers 15

test_same_originFunction · 0.85
sdp_parse_lineFunction · 0.85
ff_rtsp_connectFunction · 0.85
rtp_read_headerFunction · 0.85
libsrt_setupFunction · 0.85
gopher_openFunction · 0.85
libssh_connectFunction · 0.85
libssh_moveFunction · 0.85
mms_openFunction · 0.85
http_open_cnx_internalFunction · 0.85
ff_http_do_new_request2Function · 0.85

Calls 1

av_strlcpyFunction · 0.85

Tested by 2

test_same_originFunction · 0.68
test2Function · 0.68