Mercurial > mplayer.hg
annotate stream/url.c @ 27904:f6d60ccb095f
Use 64 bit numbers for file positions in the seek function in audio demuxer.
Hopefully fixes seeking in wav files in-between 2 and 4 GB.
author | reimar |
---|---|
date | Sun, 16 Nov 2008 10:20:58 +0000 |
parents | e96b4070ba66 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
1 /* |
902 | 2 * URL Helper |
3 * by Bertrand Baudet <bertrand_baudet@yahoo.com> | |
4 * (C) 2001, MPlayer team. | |
5 * | |
6 */ | |
7 | |
833 | 8 #include <string.h> |
9 #include <stdlib.h> | |
10 #include <stdio.h> | |
12391 | 11 #include <ctype.h> |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17048
diff
changeset
|
12 #include <inttypes.h> |
833 | 13 |
14 #include "url.h" | |
5933 | 15 #include "mp_msg.h" |
16882
dfbe8cd0e081
libmpdemux translatables to help_mp part 1 / mp_msg calls / try 2
reynaldo
parents:
16421
diff
changeset
|
16 #include "help_mp.h" |
833 | 17 |
18671 | 18 #ifndef SIZE_MAX |
19 #define SIZE_MAX ((size_t)-1) | |
20 #endif | |
21 | |
20784
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
22 URL_t *url_redirect(URL_t **url, const char *redir) { |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
23 URL_t *u = *url; |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
24 URL_t *res; |
21125
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
25 if (!strchr(redir, '/') || *redir == '/') { |
20784
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
26 char *tmp; |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
27 char *newurl = malloc(strlen(u->url) + strlen(redir) + 1); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
28 strcpy(newurl, u->url); |
21125
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
29 if (*redir == '/') { |
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
30 redir++; |
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
31 tmp = strstr(newurl, "://"); |
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
32 if (tmp) tmp = strchr(tmp + 3, '/'); |
4aff19cc00bb
Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA
reimar
parents:
20784
diff
changeset
|
33 } else |
21126 | 34 tmp = strrchr(newurl, '/'); |
20784
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
35 if (tmp) tmp[1] = 0; |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
36 strcat(newurl, redir); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
37 res = url_new(newurl); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
38 free(newurl); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
39 } else |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
40 res = url_new(redir); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
41 url_free(u); |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
42 *url = res; |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
43 return res; |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
44 } |
720206eef78b
Support URL redirections that do not specify full URL.
reimar
parents:
19271
diff
changeset
|
45 |
833 | 46 URL_t* |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
47 url_new(const char* url) { |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
48 int pos1, pos2,v6addr = 0; |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
49 URL_t* Curl = NULL; |
12391 | 50 char *escfilename=NULL; |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
51 char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; |
10056
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
52 int jumpSize = 3; |
833 | 53 |
4653
d2a7fcfeec6f
Removed the url_copy function , since it was badly implemented,
bertrand
parents:
4119
diff
changeset
|
54 if( url==NULL ) return NULL; |
d2a7fcfeec6f
Removed the url_copy function , since it was badly implemented,
bertrand
parents:
4119
diff
changeset
|
55 |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17048
diff
changeset
|
56 if (strlen(url) > (SIZE_MAX / 3 - 1)) { |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17048
diff
changeset
|
57 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17048
diff
changeset
|
58 goto err_out; |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17048
diff
changeset
|
59 } |
12391 | 60 escfilename=malloc(strlen(url)*3+1); |
61 if (!escfilename ) { | |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
62 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
63 goto err_out; |
12391 | 64 } |
65 | |
833 | 66 // Create the URL container |
18879 | 67 Curl = malloc(sizeof(URL_t)); |
833 | 68 if( Curl==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
69 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
70 goto err_out; |
833 | 71 } |
12391 | 72 |
840 | 73 // Initialisation of the URL container members |
902 | 74 memset( Curl, 0, sizeof(URL_t) ); |
840 | 75 |
17048
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
76 url_escape_string(escfilename,url); |
12391 | 77 |
833 | 78 // Copy the url in the URL container |
12391 | 79 Curl->url = strdup(escfilename); |
833 | 80 if( Curl->url==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
81 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
82 goto err_out; |
833 | 83 } |
12391 | 84 mp_msg(MSGT_OPEN,MSGL_V,"Filename for url is now %s\n",escfilename); |
833 | 85 |
86 // extract the protocol | |
12391 | 87 ptr1 = strstr(escfilename, "://"); |
833 | 88 if( ptr1==NULL ) { |
10056
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
89 // Check for a special case: "sip:" (without "//"): |
12391 | 90 if (strstr(escfilename, "sip:") == escfilename) { |
11412 | 91 ptr1 = (char *)&url[3]; // points to ':' |
10056
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
92 jumpSize = 1; |
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
93 } else { |
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
94 mp_msg(MSGT_NETWORK,MSGL_V,"Not an URL!\n"); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
95 goto err_out; |
10056
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
96 } |
833 | 97 } |
12391 | 98 pos1 = ptr1-escfilename; |
18879 | 99 Curl->protocol = malloc(pos1+1); |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
100 if( Curl->protocol==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
101 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
102 goto err_out; |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
103 } |
12637 | 104 strncpy(Curl->protocol, escfilename, pos1); |
833 | 105 Curl->protocol[pos1] = '\0'; |
106 | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
107 // jump the "://" |
10056
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
108 ptr1 += jumpSize; |
88c855a174f3
Added some special-case code for checking for "sip:" URLs (because they
rsf
parents:
9924
diff
changeset
|
109 pos1 += jumpSize; |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
110 |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
111 // check if a username:password is given |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
112 ptr2 = strstr(ptr1, "@"); |
7330
2f3fe8274028
Applied patch from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
bertrand
parents:
6513
diff
changeset
|
113 ptr3 = strstr(ptr1, "/"); |
2f3fe8274028
Applied patch from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
bertrand
parents:
6513
diff
changeset
|
114 if( ptr3!=NULL && ptr3<ptr2 ) { |
2f3fe8274028
Applied patch from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
bertrand
parents:
6513
diff
changeset
|
115 // it isn't really a username but rather a part of the path |
2f3fe8274028
Applied patch from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
bertrand
parents:
6513
diff
changeset
|
116 ptr2 = NULL; |
2f3fe8274028
Applied patch from Gregory Kovriga <gkovriga@techunix.technion.ac.il>
bertrand
parents:
6513
diff
changeset
|
117 } |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
118 if( ptr2!=NULL ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
119 // We got something, at least a username... |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
120 int len = ptr2-ptr1; |
18879 | 121 Curl->username = malloc(len+1); |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
122 if( Curl->username==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
123 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
124 goto err_out; |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
125 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
126 strncpy(Curl->username, ptr1, len); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
127 Curl->username[len] = '\0'; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
128 |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
129 ptr3 = strstr(ptr1, ":"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
130 if( ptr3!=NULL && ptr3<ptr2 ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
131 // We also have a password |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
132 int len2 = ptr2-ptr3-1; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
133 Curl->username[ptr3-ptr1]='\0'; |
18879 | 134 Curl->password = malloc(len2+1); |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
135 if( Curl->password==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
136 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
137 goto err_out; |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
138 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
139 strncpy( Curl->password, ptr3+1, len2); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
140 Curl->password[len2]='\0'; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
141 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
142 ptr1 = ptr2+1; |
12391 | 143 pos1 = ptr1-escfilename; |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
144 } |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
145 |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
146 // before looking for a port number check if we have an IPv6 type numeric address |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
147 // in IPv6 URL the numeric address should be inside square braces. |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
148 ptr2 = strstr(ptr1, "["); |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
149 ptr3 = strstr(ptr1, "]"); |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
150 ptr4 = strstr(ptr1, "/"); |
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
151 if( ptr2!=NULL && ptr3!=NULL && ptr2 < ptr3 && (!ptr4 || ptr4 > ptr3)) { |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
152 // we have an IPv6 numeric address |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
153 ptr1++; |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
154 pos1++; |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
155 ptr2 = ptr3; |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
156 v6addr = 1; |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
157 } else { |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
158 ptr2 = ptr1; |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
159 |
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
160 } |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
161 |
833 | 162 // look if the port is given |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
163 ptr2 = strstr(ptr2, ":"); |
3494
fb9de639ed30
Applied the patch from Alban Bedel <albeu@free.fr>.
bertrand
parents:
3040
diff
changeset
|
164 // If the : is after the first / it isn't the port |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
165 ptr3 = strstr(ptr1, "/"); |
3494
fb9de639ed30
Applied the patch from Alban Bedel <albeu@free.fr>.
bertrand
parents:
3040
diff
changeset
|
166 if(ptr3 && ptr3 - ptr2 < 0) ptr2 = NULL; |
833 | 167 if( ptr2==NULL ) { |
168 // No port is given | |
169 // Look if a path is given | |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
170 if( ptr3==NULL ) { |
833 | 171 // No path/filename |
172 // So we have an URL like http://www.hostname.com | |
12391 | 173 pos2 = strlen(escfilename); |
833 | 174 } else { |
175 // We have an URL like http://www.hostname.com/file.txt | |
12391 | 176 pos2 = ptr3-escfilename; |
833 | 177 } |
178 } else { | |
179 // We have an URL beginning like http://www.hostname.com:1212 | |
180 // Get the port number | |
181 Curl->port = atoi(ptr2+1); | |
12391 | 182 pos2 = ptr2-escfilename; |
833 | 183 } |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
184 if( v6addr ) pos2--; |
833 | 185 // copy the hostname in the URL container |
18879 | 186 Curl->hostname = malloc(pos2-pos1+1); |
833 | 187 if( Curl->hostname==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
188 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
189 goto err_out; |
833 | 190 } |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
191 strncpy(Curl->hostname, ptr1, pos2-pos1); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
192 Curl->hostname[pos2-pos1] = '\0'; |
833 | 193 |
194 // Look if a path is given | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
195 ptr2 = strstr(ptr1, "/"); |
833 | 196 if( ptr2!=NULL ) { |
197 // A path/filename is given | |
198 // check if it's not a trailing '/' | |
199 if( strlen(ptr2)>1 ) { | |
200 // copy the path/filename in the URL container | |
3612 | 201 Curl->file = strdup(ptr2); |
840 | 202 if( Curl->file==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
203 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
204 goto err_out; |
833 | 205 } |
206 } | |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
207 } |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
208 // Check if a filename was given or set, else set it with '/' |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
209 if( Curl->file==NULL ) { |
18879 | 210 Curl->file = malloc(2); |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
211 if( Curl->file==NULL ) { |
16908
bd4cac0d5e0e
Changed MSGTR_MPDEMUX_URL_MallocFailed to MSGTR_MemAllocFailed (msg defined two times in help_mp-en.h)
ptt
parents:
16882
diff
changeset
|
212 mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
213 goto err_out; |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
214 } |
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
215 strcpy(Curl->file, "/"); |
833 | 216 } |
217 | |
12391 | 218 free(escfilename); |
833 | 219 return Curl; |
16421
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
220 err_out: |
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
221 if (escfilename) free(escfilename); |
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
222 if (Curl) url_free(Curl); |
c41e22d77214
memleak fix, escfilename was not freed for an invalid url
reimar
parents:
12637
diff
changeset
|
223 return NULL; |
833 | 224 } |
225 | |
226 void | |
902 | 227 url_free(URL_t* url) { |
1530
3effaac0ddb7
silly bug fixed - thanx Szekeres Istvan <szekeres@webvilag.com>
arpi
parents:
997
diff
changeset
|
228 if(!url) return; |
833 | 229 if(url->url) free(url->url); |
230 if(url->protocol) free(url->protocol); | |
231 if(url->hostname) free(url->hostname); | |
840 | 232 if(url->file) free(url->file); |
902 | 233 if(url->username) free(url->username); |
234 if(url->password) free(url->password); | |
833 | 235 free(url); |
236 } | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
237 |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
238 |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
239 /* Replace escape sequences in an URL (or a part of an URL) */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
240 /* works like strcpy(), but without return argument */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
241 void |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
242 url_unescape_string(char *outbuf, const char *inbuf) |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
243 { |
12391 | 244 unsigned char c,c1,c2; |
245 int i,len=strlen(inbuf); | |
246 for (i=0;i<len;i++){ | |
247 c = inbuf[i]; | |
248 if (c == '%' && i<len-2) { //must have 2 more chars | |
249 c1 = toupper(inbuf[i+1]); // we need uppercase characters | |
250 c2 = toupper(inbuf[i+2]); | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
251 if ( ((c1>='0' && c1<='9') || (c1>='A' && c1<='F')) && |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
252 ((c2>='0' && c2<='9') || (c2>='A' && c2<='F')) ) { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
253 if (c1>='0' && c1<='9') c1-='0'; |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
254 else c1-='A'-10; |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
255 if (c2>='0' && c2<='9') c2-='0'; |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11412
diff
changeset
|
256 else c2-='A'-10; |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
257 c = (c1<<4) + c2; |
12391 | 258 i=i+2; //only skip next 2 chars if valid esc |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
259 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
260 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
261 *outbuf++ = c; |
12391 | 262 } |
263 *outbuf++='\0'; //add nullterm to string | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
264 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
265 |
17048
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
266 static void |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
267 url_escape_string_part(char *outbuf, const char *inbuf) { |
12391 | 268 unsigned char c,c1,c2; |
269 int i,len=strlen(inbuf); | |
270 | |
271 for (i=0;i<len;i++) { | |
272 c = inbuf[i]; | |
273 if ((c=='%') && i<len-2 ) { //need 2 more characters | |
274 c1=toupper(inbuf[i+1]); c2=toupper(inbuf[i+2]); // need uppercase chars | |
275 } else { | |
276 c1=129; c2=129; //not escape chars | |
277 } | |
278 | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
279 if( (c >= 'A' && c <= 'Z') || |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
280 (c >= 'a' && c <= 'z') || |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
281 (c >= '0' && c <= '9') || |
17048
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
282 (c >= 0x7f)) { |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
283 *outbuf++ = c; |
12391 | 284 } else if ( c=='%' && ((c1 >= '0' && c1 <= '9') || (c1 >= 'A' && c1 <= 'F')) && |
285 ((c2 >= '0' && c2 <= '9') || (c2 >= 'A' && c2 <= 'F'))) { | |
286 // check if part of an escape sequence | |
287 *outbuf++=c; // already | |
288 | |
289 // dont escape again | |
16882
dfbe8cd0e081
libmpdemux translatables to help_mp part 1 / mp_msg calls / try 2
reynaldo
parents:
16421
diff
changeset
|
290 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_URL_StringAlreadyEscaped,c,c1,c2); |
12391 | 291 // error as this should not happen against RFC 2396 |
292 // to escape a string twice | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
293 } else { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
294 /* all others will be escaped */ |
12391 | 295 c1 = ((c & 0xf0) >> 4); |
296 c2 = (c & 0x0f); | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
297 if (c1 < 10) c1+='0'; |
9924 | 298 else c1+='A'-10; |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
299 if (c2 < 10) c2+='0'; |
9924 | 300 else c2+='A'-10; |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
301 *outbuf++ = '%'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
302 *outbuf++ = c1; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
303 *outbuf++ = c2; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
304 } |
12391 | 305 } |
306 *outbuf++='\0'; | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
307 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
308 |
17048
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
309 /* Replace specific characters in the URL string by an escape sequence */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
310 /* works like strcpy(), but without return argument */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
311 void |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
312 url_escape_string(char *outbuf, const char *inbuf) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
313 unsigned char c; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
314 int i = 0,j,len = strlen(inbuf); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
315 char* tmp,*unesc = NULL, *in; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
316 |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
317 // Look if we have an ip6 address, if so skip it there is |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
318 // no need to escape anything in there. |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
319 tmp = strstr(inbuf,"://["); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
320 if(tmp) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
321 tmp = strchr(tmp+4,']'); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
322 if(tmp && (tmp[1] == '/' || tmp[1] == ':' || |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
323 tmp[1] == '\0')) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
324 i = tmp+1-inbuf; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
325 strncpy(outbuf,inbuf,i); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
326 outbuf += i; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
327 tmp = NULL; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
328 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
329 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
330 |
25795
e96b4070ba66
Clear tmp between ip6 check and string escape to prevent reuse of the
rtogni
parents:
25620
diff
changeset
|
331 tmp = NULL; |
17048
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
332 while(i < len) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
333 // look for the next char that must be kept |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
334 for (j=i;j<len;j++) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
335 c = inbuf[j]; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
336 if(c=='-' || c=='_' || c=='.' || c=='!' || c=='~' || /* mark characters */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
337 c=='*' || c=='\'' || c=='(' || c==')' || /* do not touch escape character */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
338 c==';' || c=='/' || c=='?' || c==':' || c=='@' || /* reserved characters */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
339 c=='&' || c=='=' || c=='+' || c=='$' || c==',') /* see RFC 2396 */ |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
340 break; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
341 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
342 // we are on a reserved char, write it out |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
343 if(j == i) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
344 *outbuf++ = c; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
345 i++; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
346 continue; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
347 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
348 // we found one, take that part of the string |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
349 if(j < len) { |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
350 if(!tmp) tmp = malloc(len+1); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
351 strncpy(tmp,inbuf+i,j-i); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
352 tmp[j-i] = '\0'; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
353 in = tmp; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
354 } else // take the rest of the string |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
355 in = (char*)inbuf+i; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
356 |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
357 if(!unesc) unesc = malloc(len+1); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
358 // unescape first to avoid escaping escape |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
359 url_unescape_string(unesc,in); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
360 // then escape, including mark and other reserved chars |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
361 // that can come from escape sequences |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
362 url_escape_string_part(outbuf,unesc); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
363 outbuf += strlen(outbuf); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
364 i += strlen(in); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
365 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
366 *outbuf = '\0'; |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
367 if(tmp) free(tmp); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
368 if(unesc) free(unesc); |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
369 } |
9e02b9cb171b
Fix URL escaping to correctly handle URL containing an ip6 address or
albeu
parents:
16908
diff
changeset
|
370 |
25620
53e5107ea80d
Fix illegal identifiers, names starting with __ are reserved for the system.
diego
parents:
21126
diff
changeset
|
371 #ifdef URL_DEBUG |
4119
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
372 void |
9690
a9b7b6055563
Added support for IPv6 numeric url like: http://[3ffe:400:100::1]:80/file
bertrand
parents:
7809
diff
changeset
|
373 url_debug(const URL_t *url) { |
4119
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
374 if( url==NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
375 printf("URL pointer NULL\n"); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
376 return; |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
377 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
378 if( url->url!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
379 printf("url=%s\n", url->url ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
380 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
381 if( url->protocol!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
382 printf("protocol=%s\n", url->protocol ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
383 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
384 if( url->hostname!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
385 printf("hostname=%s\n", url->hostname ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
386 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
387 printf("port=%d\n", url->port ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
388 if( url->file!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
389 printf("file=%s\n", url->file ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
390 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
391 if( url->username!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
392 printf("username=%s\n", url->username ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
393 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
394 if( url->password!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
395 printf("password=%s\n", url->password ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
396 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
397 } |
25620
53e5107ea80d
Fix illegal identifiers, names starting with __ are reserved for the system.
diego
parents:
21126
diff
changeset
|
398 #endif /* URL_DEBUG */ |