|
| static bool | parse_query_string (struct UrlQueryList *list, char *src) |
| | Parse a URL query string.
|
| static enum UrlScheme | get_scheme (const char *src, const regmatch_t *match) |
| | Extract the scheme part from a matched URL.
|
| static struct Url * | url_new (void) |
| | Create a Url.
|
| void | url_free (struct Url **ptr) |
| | Free the contents of a URL.
|
| void | url_pct_encode (char *buf, size_t buflen, const char *src) |
| | Percent-encode a string.
|
| int | url_pct_decode (char *s) |
| | Decode a percent-encoded string.
|
| enum UrlScheme | url_check_scheme (const char *str) |
| | Check the protocol of a URL.
|
| struct Url * | url_parse (const char *src) |
| | Fill in Url.
|
| int | url_tobuffer (const struct Url *url, struct Buffer *buf, uint8_t flags) |
| | Output the URL string for a given Url object.
|
| int | url_tostring (const struct Url *url, char *dest, size_t len, uint8_t flags) |
| | Output the URL string for a given Url object.
|
Parse and identify different URL schemes.
- Authors
- Richard Russon
- Pietro Cerutti
- Thomas Klausner
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file url.c.
| void url_pct_encode |
( |
char * | buf, |
|
|
size_t | buflen, |
|
|
const char * | src ) |
Percent-encode a string.
- Parameters
-
| buf | Buffer for the result |
| buflen | Length of buffer |
| src | String to encode |
e.g. turn "hello world" into "hello%20world"
Control characters, the URL delimiters and the characters that RFC3986 doesn't allow anywhere in a URL are encoded, so that url_parse() can read the result back, e.g. an Exchange user name "domain\user".
Definition at line 156 of file url.c.
157{
158 static const char *hex = "0123456789ABCDEF";
159
160 if (!buf)
161 return;
162
163 *buf = '\0';
164 buflen--;
165 while (src && *src && (buflen != 0))
166 {
167 const unsigned char c = *src;
168 if ((c < 0x20) || (c == 0x7f) || strchr(" \"#%&/:<=>?\\^`{|}", c))
169 {
170 if (buflen < 3)
171 break;
172
173 *buf++ = '%';
174 *buf++ = hex[(c >> 4) & 0xf];
175 *buf++ = hex[c & 0xf];
176 src++;
177 buflen -= 3;
178 continue;
179 }
180 *buf++ = *src++;
181 buflen--;
182 }
183 *buf = '\0';
184}