Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

inet/url.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  URL

Defines

#define DEFAULT_FTP_DATA_PORT   20
#define DEFAULT_FTP_PORT   21
#define DEFAULT_TELNET_PORT   23
#define DEFAULT_SMTP_PORT   25
#define DEFAULT_TIME_PORT   37
#define DEFAULT_DNS_PORT   42
#define DEFAULT_WHOIS_PORT   43
#define DEFAULT_TFTP_PORT   69
#define DEFAULT_GOPHER_PORT   70
#define DEFAULT_FINGER_PORT   79
#define DEFAULT_HTTP_PORT   80
#define DEFAULT_POP3_PORT   110
#define DEFAULT_NNTP_PORT   119
#define DEFAULT_WAIS_PORT   210
#define DEFAULT_HTTPS_PORT   443
#define DEFAULT_SNEWS_PORT   563
#define DEFAULT_PROSPERO_PORT   1525

Functions

void free_url (URL *url)
 Free an URL structure.

URLparse_url (const char *urlString)
 Parse an URL and return its components.

unsigned url_decode (char *str, unsigned len)
 Decode URL-encoded data.

char * url_encode (char *s, unsigned len)
 URL-encode according to RFC1738.


Define Documentation

#define DEFAULT_DNS_PORT   42
 

Definition at line 9 of file url.h.

#define DEFAULT_FINGER_PORT   79
 

Definition at line 13 of file url.h.

#define DEFAULT_FTP_DATA_PORT   20
 

Definition at line 4 of file url.h.

#define DEFAULT_FTP_PORT   21
 

Definition at line 5 of file url.h.

#define DEFAULT_GOPHER_PORT   70
 

Definition at line 12 of file url.h.

#define DEFAULT_HTTP_PORT   80
 

Definition at line 14 of file url.h.

Referenced by http_connect().

#define DEFAULT_HTTPS_PORT   443
 

Definition at line 18 of file url.h.

#define DEFAULT_NNTP_PORT   119
 

Definition at line 16 of file url.h.

#define DEFAULT_POP3_PORT   110
 

Definition at line 15 of file url.h.

#define DEFAULT_PROSPERO_PORT   1525
 

Definition at line 20 of file url.h.

#define DEFAULT_SMTP_PORT   25
 

Definition at line 7 of file url.h.

#define DEFAULT_SNEWS_PORT   563
 

Definition at line 19 of file url.h.

#define DEFAULT_TELNET_PORT   23
 

Definition at line 6 of file url.h.

#define DEFAULT_TFTP_PORT   69
 

Definition at line 11 of file url.h.

#define DEFAULT_TIME_PORT   37
 

Definition at line 8 of file url.h.

#define DEFAULT_WAIS_PORT   210
 

Definition at line 17 of file url.h.

#define DEFAULT_WHOIS_PORT   43
 

Definition at line 10 of file url.h.


Function Documentation

void free_url URL   url
 

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.

Parameters:
url  Pointer to URL structure to free.

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().

URL* parse_url const char *    urlString
 

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.

Parameters:
urlString  URL string to parse
Returns:
pointer to an URL structure containing all components, or NULL if out of memory. This has to be freed by a call to free_url() after use.
Todo:
perhaps we should detect some syntax errors..

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().

unsigned url_decode char *    str,
unsigned    len
 

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".

Parameters:
str  Data to decode. The data is decoded in-place, and also functions as the target buffer.
len  number of encoded characters to decode.
Returns:
Number of decoded characters.

Definition at line 271 of file url.cpp.

References htoi(), and src.

char* url_encode char *    s,
unsigned    len
 

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).

Parameters:
s  String to encode
len  Number of string characters to encode
Returns:
Pointer to encoded string. (has to be free'd after use)

Definition at line 234 of file url.cpp.

References hexchars.


Generated on Sun Aug 4 21:47:39 2002 for k/os mp3v2 by doxygen1.2.16