#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <misc.h>
#include <ctype.h>
#include "inet/url.h"
Go to the source code of this file.
Data Structures | |
struct | scheme_t |
Functions | |
unsigned | port_for_scheme (char *scheme) |
Return the default port for a given scheme. | |
int | htoi (char *s) |
Convert a 2-digit hexadecimal string to an int. | |
void | free_url (URL *url) |
Free an URL structure. | |
URL * | parse_url (const char *urlString) |
Parse an URL and return its components. | |
char * | url_encode (char *s, unsigned len) |
URL-encode according to RFC1738. | |
unsigned | url_decode (char *str, unsigned len) |
Decode URL-encoded data. | |
Variables | |
scheme_t | schemes [] |
unsigned char | hexchars [] = "0123456789ABCDEF" |
|
Free an URL structure. Use this function to free all memory allocated by an URL structure, that was previously allocated by parse_url(). All strings and the structure itself are free'd.
Definition at line 103 of file url.cpp. References URL::fragment, URL::host, URL::pass, URL::path, URL::query, URL::scheme, and URL::user. Referenced by http_connect(). |
|
Convert a 2-digit hexadecimal string to an int.
Definition at line 76 of file url.cpp. Referenced by url_decode(). |
|
Parse an URL and return its components. This function returns an URL data structure, returning any of the various components of the URL that are present. This includes the scheme, host, port, user, pass, path, query, and fragment. The parsing is done according to RFC 1738 (atleast, i hope so, send me a mail, if you find an error!) If the URL contains a scheme but no port, parse_url() tries to find out the default port for this scheme.
Definition at line 133 of file url.cpp. References URL::fragment, URL::host, URL::pass, URL::path, URL::port, port_for_scheme(), URL::query, URL::scheme, and URL::user. Referenced by http_connect(), and http_get(). |
|
Return the default port for a given scheme.
Definition at line 55 of file url.cpp. References scheme_t::port, and scheme_t::scheme. Referenced by parse_url(). |
|
Decode URL-encoded data. Returns a string in which the sequences with percent (%) signs followed by two hex digits have been replaced with literal characters. For example, the string "foo%20bar%40baz" decodes into "foo bar@baz".
|
|
URL-encode according to RFC1738. Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits. This is the encoding described in RFC1738 for protecting literal characters from being interpreted as special URL delimiters, and for protecting URL's from being mangled by transmission media with character conversions (like some email systems).
Definition at line 234 of file url.cpp. References hexchars. |
|
Definition at line 67 of file url.cpp. Referenced by url_encode(). |
|
Initial value: { {"ftp", DEFAULT_FTP_PORT}, {"telnet", DEFAULT_TELNET_PORT}, {"mailto", DEFAULT_SMTP_PORT}, {"gopher", DEFAULT_GOPHER_PORT}, {"http", DEFAULT_HTTP_PORT}, {"nntp", DEFAULT_NNTP_PORT}, {"news", DEFAULT_NNTP_PORT}, {"wais", DEFAULT_WAIS_PORT}, {"https", DEFAULT_HTTPS_PORT}, {"snews", DEFAULT_SNEWS_PORT}, { NULL, 0 } } |