mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Cleanups for parse_url
This commit is contained in:
parent
d4bed832cc
commit
1d4471ee16
37
net_http.c
37
net_http.c
@ -39,41 +39,38 @@ enum
|
|||||||
static bool net_http_parse_url(char *url, char **domain,
|
static bool net_http_parse_url(char *url, char **domain,
|
||||||
int *port, char **location)
|
int *port, char **location)
|
||||||
{
|
{
|
||||||
char* scan;
|
char* scan;
|
||||||
|
|
||||||
if (strncmp(url, "http://", strlen("http://")) != 0)
|
if (strncmp(url, "http://", strlen("http://")) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
scan = url + strlen("http://");
|
scan = url + strlen("http://");
|
||||||
*domain = scan;
|
*domain = scan;
|
||||||
|
|
||||||
while (*scan!='/' && *scan!=':' && *scan!='\0')
|
while (*scan != '/' && *scan != ':' && *scan != '\0')
|
||||||
scan++;
|
scan++;
|
||||||
|
|
||||||
if (*scan == '\0')
|
if (*scan == '\0')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (*scan == ':')
|
*scan = '\0';
|
||||||
{
|
*port = 80;
|
||||||
*scan='\0';
|
|
||||||
|
|
||||||
if (!isdigit(scan[1]))
|
if (*scan == ':')
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!isdigit(scan[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*port = strtoul(scan+1, &scan, 10);
|
*port = strtoul(scan + 1, &scan, 10);
|
||||||
|
|
||||||
if (*scan != '/')
|
if (*scan != '/')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else /* known '/' */
|
|
||||||
{
|
|
||||||
*scan='\0';
|
|
||||||
*port=80;
|
|
||||||
}
|
|
||||||
|
|
||||||
*location=scan+1;
|
*location = scan + 1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int net_http_new_socket(const char * domain, int port)
|
static int net_http_new_socket(const char * domain, int port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user