mirror of
https://github.com/mpv-player/mpv
synced 2025-01-08 16:10:29 +00:00
Modified code for path/filename extraction.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@998 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
70faf50935
commit
4b793fee5e
9
url.c
9
url.c
@ -39,7 +39,7 @@ url_new(char* url) {
|
|||||||
// extract the protocol
|
// extract the protocol
|
||||||
ptr1 = strstr(url, "://");
|
ptr1 = strstr(url, "://");
|
||||||
if( ptr1==NULL ) {
|
if( ptr1==NULL ) {
|
||||||
printf("Malformed URL or not an URL!\n");
|
printf("Not an URL!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pos1 = ptr1-url;
|
pos1 = ptr1-url;
|
||||||
@ -68,7 +68,7 @@ url_new(char* url) {
|
|||||||
pos2 = ptr2-url;
|
pos2 = ptr2-url;
|
||||||
}
|
}
|
||||||
// copy the hostname in the URL container
|
// copy the hostname in the URL container
|
||||||
Curl->hostname = (char*)malloc(strlen(url)+1);
|
Curl->hostname = (char*)malloc(pos2-pos1-3+1);
|
||||||
if( Curl->hostname==NULL ) {
|
if( Curl->hostname==NULL ) {
|
||||||
printf("Memory allocation failed!\n");
|
printf("Memory allocation failed!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -88,11 +88,10 @@ url_new(char* url) {
|
|||||||
printf("Memory allocation failed!\n");
|
printf("Memory allocation failed!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
Curl->file[0]='/';
|
strcpy(Curl->file, ptr2);
|
||||||
strcpy(Curl->file+1, ptr2+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if a filenme was given or set else set it with '/'
|
// Check if a filenme was given or set, else set it with '/'
|
||||||
if( Curl->file==NULL ) {
|
if( Curl->file==NULL ) {
|
||||||
Curl->file = (char*)malloc(2);
|
Curl->file = (char*)malloc(2);
|
||||||
if( Curl->file==NULL ) {
|
if( Curl->file==NULL ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user