mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-04 22:48:49 +00:00
gst/rtsp/rtspurl.c: Make parsing of urls suck slightly less.
Original commit message from CVS: * gst/rtsp/rtspurl.c: (rtsp_url_parse): Make parsing of urls suck slightly less.
This commit is contained in:
parent
f8efd7186b
commit
b8d3badb18
2 changed files with 21 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-05-08 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/rtsp/rtspurl.c: (rtsp_url_parse):
|
||||||
|
Make parsing of urls suck slightly less.
|
||||||
|
|
||||||
2006-05-08 Edward Hervey <edward@fluendo.com>
|
2006-05-08 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* autogen.sh: (CONFIGURE_DEF_OPT):
|
* autogen.sh: (CONFIGURE_DEF_OPT):
|
||||||
|
|
|
@ -37,7 +37,7 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
|
||||||
res = g_new0 (RTSPUrl, 1);
|
res = g_new0 (RTSPUrl, 1);
|
||||||
|
|
||||||
if (urlstr == NULL)
|
if (urlstr == NULL)
|
||||||
return RTSP_EINVAL;
|
goto invalid;
|
||||||
|
|
||||||
p = (gchar *) urlstr;
|
p = (gchar *) urlstr;
|
||||||
if (g_str_has_prefix (p, RTSP_PROTO)) {
|
if (g_str_has_prefix (p, RTSP_PROTO)) {
|
||||||
|
@ -46,30 +46,31 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
|
||||||
} else if (g_str_has_prefix (p, RTSPU_PROTO)) {
|
} else if (g_str_has_prefix (p, RTSPU_PROTO)) {
|
||||||
res->protocol = RTSP_PROTO_UDP;
|
res->protocol = RTSP_PROTO_UDP;
|
||||||
p += RTSPU_PROTO_LEN;
|
p += RTSPU_PROTO_LEN;
|
||||||
} else {
|
} else
|
||||||
return RTSP_EINVAL;
|
goto invalid;
|
||||||
}
|
|
||||||
|
|
||||||
slash = strstr (p, "/");
|
slash = strstr (p, "/");
|
||||||
at = g_strrstr (p, "@");
|
at = strstr (p, "@");
|
||||||
|
|
||||||
if (at && slash && at > slash)
|
if (at && slash && at > slash)
|
||||||
at = NULL;
|
at = NULL;
|
||||||
|
|
||||||
if (at) {
|
if (at) {
|
||||||
col = g_strrstr (p, ":");
|
col = strstr (p, ":");
|
||||||
|
|
||||||
if (col == NULL)
|
/* must have a ':' and it must be before the '@' */
|
||||||
return RTSP_EINVAL;
|
if (col == NULL || col > at)
|
||||||
|
goto invalid;
|
||||||
|
|
||||||
res->user = g_strndup (p, col - p);
|
res->user = g_strndup (p, col - p);
|
||||||
col++;
|
col++;
|
||||||
res->passwd = g_strndup (col, col - at);
|
res->passwd = g_strndup (col, col - at);
|
||||||
|
|
||||||
|
/* move to host */
|
||||||
p = at + 1;
|
p = at + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
col = g_strrstr (p, ":");
|
col = strstr (p, ":");
|
||||||
if (col) {
|
if (col) {
|
||||||
res->host = g_strndup (p, col - p);
|
res->host = g_strndup (p, col - p);
|
||||||
p = col + 1;
|
p = col + 1;
|
||||||
|
@ -92,6 +93,12 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
|
||||||
*url = res;
|
*url = res;
|
||||||
|
|
||||||
return RTSP_OK;
|
return RTSP_OK;
|
||||||
|
|
||||||
|
invalid:
|
||||||
|
{
|
||||||
|
rtsp_url_free (res);
|
||||||
|
return RTSP_EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue