Mercurial > mplayer.hg
annotate libmpdemux/url.c @ 7177:cba37985dec5
v0.9 of my compile+benchmark script, designed for my local boxes, shared on
NFS, etc..
Read README, and RTFS before using it.
Oh, and feel free to reverse/del, but al3x wanted it.
author | gabucino |
---|---|
date | Fri, 30 Aug 2002 21:16:52 +0000 |
parents | 6e9d7a6b1806 |
children | 2f3fe8274028 |
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> | |
11 | |
12 #include "url.h" | |
5933 | 13 #include "mp_msg.h" |
833 | 14 |
15 URL_t* | |
902 | 16 url_new(char* url) { |
833 | 17 int pos1, pos2; |
18 URL_t* Curl; | |
3494
fb9de639ed30
Applied the patch from Alban Bedel <albeu@free.fr>.
bertrand
parents:
3040
diff
changeset
|
19 char *ptr1, *ptr2, *ptr3; |
833 | 20 |
4653
d2a7fcfeec6f
Removed the url_copy function , since it was badly implemented,
bertrand
parents:
4119
diff
changeset
|
21 if( url==NULL ) return NULL; |
d2a7fcfeec6f
Removed the url_copy function , since it was badly implemented,
bertrand
parents:
4119
diff
changeset
|
22 |
833 | 23 // Create the URL container |
24 Curl = (URL_t*)malloc(sizeof(URL_t)); | |
25 if( Curl==NULL ) { | |
5933 | 26 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
1631 | 27 return NULL; |
833 | 28 } |
840 | 29 // Initialisation of the URL container members |
902 | 30 memset( Curl, 0, sizeof(URL_t) ); |
840 | 31 |
833 | 32 // Copy the url in the URL container |
3612 | 33 Curl->url = strdup(url); |
833 | 34 if( Curl->url==NULL ) { |
5933 | 35 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
1631 | 36 return NULL; |
833 | 37 } |
38 | |
39 // extract the protocol | |
40 ptr1 = strstr(url, "://"); | |
41 if( ptr1==NULL ) { | |
5933 | 42 mp_msg(MSGT_NETWORK,MSGL_V,"Not an URL!\n"); |
833 | 43 return NULL; |
44 } | |
45 pos1 = ptr1-url; | |
46 Curl->protocol = (char*)malloc(pos1+1); | |
47 strncpy(Curl->protocol, url, pos1); | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
48 if( Curl->protocol==NULL ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
49 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
50 return NULL; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
51 } |
833 | 52 Curl->protocol[pos1] = '\0'; |
53 | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
54 // jump the "://" |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
55 ptr1 += 3; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
56 pos1 += 3; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
57 |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
58 // check if a username:password is given |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
59 ptr2 = strstr(ptr1, "@"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
60 if( ptr2!=NULL ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
61 // We got something, at least a username... |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
62 int len = ptr2-ptr1; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
63 Curl->username = (char*)malloc(len+1); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
64 if( Curl->username==NULL ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
65 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
66 return NULL; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
67 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
68 strncpy(Curl->username, ptr1, len); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
69 Curl->username[len] = '\0'; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
70 |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
71 ptr3 = strstr(ptr1, ":"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
72 if( ptr3!=NULL && ptr3<ptr2 ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
73 // We also have a password |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
74 int len2 = ptr2-ptr3-1; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
75 Curl->username[ptr3-ptr1]='\0'; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
76 Curl->password = (char*)malloc(len2+1); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
77 if( Curl->password==NULL ) { |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
78 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
79 return NULL; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
80 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
81 strncpy( Curl->password, ptr3+1, len2); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
82 Curl->password[len2]='\0'; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
83 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
84 ptr1 = ptr2+1; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
85 pos1 = ptr1-url; |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
86 } |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
87 |
833 | 88 // look if the port is given |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
89 ptr2 = strstr(ptr1, ":"); |
3494
fb9de639ed30
Applied the patch from Alban Bedel <albeu@free.fr>.
bertrand
parents:
3040
diff
changeset
|
90 // 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
|
91 ptr3 = strstr(ptr1, "/"); |
3494
fb9de639ed30
Applied the patch from Alban Bedel <albeu@free.fr>.
bertrand
parents:
3040
diff
changeset
|
92 if(ptr3 && ptr3 - ptr2 < 0) ptr2 = NULL; |
833 | 93 if( ptr2==NULL ) { |
94 // No port is given | |
95 // Look if a path is given | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
96 ptr2 = strstr(ptr1, "/"); |
833 | 97 if( ptr2==NULL ) { |
98 // No path/filename | |
99 // So we have an URL like http://www.hostname.com | |
100 pos2 = strlen(url); | |
101 } else { | |
102 // We have an URL like http://www.hostname.com/file.txt | |
103 pos2 = ptr2-url; | |
104 } | |
105 } else { | |
106 // We have an URL beginning like http://www.hostname.com:1212 | |
107 // Get the port number | |
108 Curl->port = atoi(ptr2+1); | |
109 pos2 = ptr2-url; | |
110 } | |
111 // copy the hostname in the URL container | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
112 Curl->hostname = (char*)malloc(pos2-pos1+1); |
833 | 113 if( Curl->hostname==NULL ) { |
5933 | 114 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
1631 | 115 return NULL; |
833 | 116 } |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
117 strncpy(Curl->hostname, ptr1, pos2-pos1); |
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
118 Curl->hostname[pos2-pos1] = '\0'; |
833 | 119 |
120 // Look if a path is given | |
6513
6e9d7a6b1806
Added support for URLs that contain an username:password
bertrand
parents:
5933
diff
changeset
|
121 ptr2 = strstr(ptr1, "/"); |
833 | 122 if( ptr2!=NULL ) { |
123 // A path/filename is given | |
124 // check if it's not a trailing '/' | |
125 if( strlen(ptr2)>1 ) { | |
126 // copy the path/filename in the URL container | |
3612 | 127 Curl->file = strdup(ptr2); |
840 | 128 if( Curl->file==NULL ) { |
5933 | 129 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
1631 | 130 return NULL; |
833 | 131 } |
132 } | |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
133 } |
997 | 134 // Check if a filenme 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
|
135 if( Curl->file==NULL ) { |
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
136 Curl->file = (char*)malloc(2); |
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
137 if( Curl->file==NULL ) { |
5933 | 138 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); |
1631 | 139 return NULL; |
869
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
140 } |
e350849ff400
Url given without a filename/path get the filename/path '/'
bertrand
parents:
840
diff
changeset
|
141 strcpy(Curl->file, "/"); |
833 | 142 } |
143 | |
144 return Curl; | |
145 } | |
146 | |
147 void | |
902 | 148 url_free(URL_t* url) { |
1530
3effaac0ddb7
silly bug fixed - thanx Szekeres Istvan <szekeres@webvilag.com>
arpi
parents:
997
diff
changeset
|
149 if(!url) return; |
833 | 150 if(url->url) free(url->url); |
151 if(url->protocol) free(url->protocol); | |
152 if(url->hostname) free(url->hostname); | |
840 | 153 if(url->file) free(url->file); |
902 | 154 if(url->username) free(url->username); |
155 if(url->password) free(url->password); | |
833 | 156 free(url); |
157 } | |
3496
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
158 |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
159 |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
160 /* 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
|
161 /* 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
|
162 /* unescape_url_string comes from ASFRecorder */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
163 void |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
164 url_unescape_string(char *outbuf, char *inbuf) |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
165 { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
166 unsigned char c; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
167 do { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
168 c = *inbuf++; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
169 if (c == '%') { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
170 unsigned char c1 = *inbuf++; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
171 unsigned char c2 = *inbuf++; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
172 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
|
173 ((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
|
174 if (c1>='0' && c1<='9') c1-='0'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
175 else c1-='A'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
176 if (c2>='0' && c2<='9') c2-='0'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
177 else c2-='A'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
178 c = (c1<<4) + c2; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
179 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
180 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
181 *outbuf++ = c; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
182 } while (c != '\0'); |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
183 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
184 |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
185 /* Replace specific characters in the URL string by an escape sequence */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
186 /* 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
|
187 /* escape_url_string comes from ASFRecorder */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
188 void |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
189 url_escape_string(char *outbuf, char *inbuf) { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
190 unsigned char c; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
191 do { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
192 c = *inbuf++; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
193 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
|
194 (c >= 'a' && c <= 'z') || |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
195 (c >= '0' && c <= '9') || |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
196 (c >= 0x7f) || /* fareast languages(Chinese, Korean, Japanese) */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
197 c=='-' || c=='_' || c=='.' || c=='!' || c=='~' || /* mark characters */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
198 c=='*' || c=='\'' || c=='(' || c==')' || c=='%' || /* do not touch escape character */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
199 c==';' || c=='/' || c=='?' || c==':' || c=='@' || /* reserved characters */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
200 c=='&' || c=='=' || c=='+' || c=='$' || c==',' || /* see RFC 2396 */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
201 c=='\0' ) { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
202 *outbuf++ = c; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
203 } else { |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
204 /* all others will be escaped */ |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
205 unsigned char c1 = ((c & 0xf0) >> 4); |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
206 unsigned char c2 = (c & 0x0f); |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
207 if (c1 < 10) c1+='0'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
208 else c1+='A'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
209 if (c2 < 10) c2+='0'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
210 else c2+='A'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
211 *outbuf++ = '%'; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
212 *outbuf++ = c1; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
213 *outbuf++ = c2; |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
214 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
215 } while (c != '\0'); |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
216 } |
5c8a533dfa09
Added 2 functions to escape/unescape the url as described in the RFC 2396.
bertrand
parents:
3494
diff
changeset
|
217 |
4119
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
218 #ifdef __URL_DEBUG |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
219 void |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
220 url_debug(URL_t *url) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
221 if( url==NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
222 printf("URL pointer NULL\n"); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
223 return; |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
224 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
225 if( url->url!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
226 printf("url=%s\n", url->url ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
227 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
228 if( url->protocol!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
229 printf("protocol=%s\n", url->protocol ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
230 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
231 if( url->hostname!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
232 printf("hostname=%s\n", url->hostname ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
233 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
234 printf("port=%d\n", url->port ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
235 if( url->file!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
236 printf("file=%s\n", url->file ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
237 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
238 if( url->username!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
239 printf("username=%s\n", url->username ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
240 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
241 if( url->password!=NULL ) { |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
242 printf("password=%s\n", url->password ); |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
243 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
244 } |
639b3b47b138
Added a debug function to print the struct's variables.
bertrand
parents:
3612
diff
changeset
|
245 #endif //__URL_DEBUG |