Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

url.h File Reference


Detailed Description

URL handling of specific formats.

Author:
Raphael Manfredi
Date:
2002-2003

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  url_params_t
 Parsed URL parameters (from query string). More...


Defines

#define url_params_count(x)   ((x)->count)

Enumerations

enum  url_policy_t {
  URL_POLICY_ALLOW_IP_AS_HOST = (1 << 0), URL_POLICY_ALLOW_LOCAL_HOSTS = (1 << 1), URL_POLICY_ALLOW_ANY_PORT = (1 << 2), URL_POLICY_ALLOW_STATIC_FILES = (1 << 3),
  URL_POLICY_ALLOW_ANY_CHAR = (1 << 4), URL_POLICY_GWC_RULES = 0
}

Functions

gchar * url_escape (const gchar *url)
 Escape undesirable characters using xx, where xx is an hex code.

gchar * url_escape_query (const gchar *url)
 Same as url_escape(), but '+' are also escaped for the query string.

gint url_escape_into (const gchar *url, gchar *target, gint len)
 Escape undesirable characters using xx, where xx is an hex code.

gchar * url_escape_cntrl (gchar *url)
 Escape control characters using xx, where xx is an hex code.

gchar * url_unescape (gchar *url, gboolean inplace)
 Unescape string, in-place if `inplace' is TRUE.

url_params_turl_params_parse (gchar *query)
 Parse all the parameters in the URL query string.

const gchar * url_params_get (url_params_t *up, const gchar *name)
 Get the value of a parameter, or NULL if the parameter is not present.

void url_params_free (url_params_t *up)
 Dispose of the url_params_t structure.

gchar * url_normalize (gchar *url, url_policy_t pol)
 
Attention:
NB: May modify ``url'' in all cased; pass a copy if necessary!



Define Documentation

#define url_params_count  )     ((x)->count)
 


Enumeration Type Documentation

enum url_policy_t
 

Enumeration values:
URL_POLICY_ALLOW_IP_AS_HOST 
URL_POLICY_ALLOW_LOCAL_HOSTS 
URL_POLICY_ALLOW_ANY_PORT 
URL_POLICY_ALLOW_STATIC_FILES 
URL_POLICY_ALLOW_ANY_CHAR 
URL_POLICY_GWC_RULES 


Function Documentation

gchar* url_escape const gchar *  url  ) 
 

Escape undesirable characters using xx, where xx is an hex code.

Returns:
argument if no escaping is necessary, or a new string otherwise.

gchar* url_escape_cntrl gchar *  url  ) 
 

Escape control characters using xx, where xx is an hex code.

Returns:
argument if no escaping is necessary, or a new string otherwise.

gint url_escape_into const gchar *  url,
gchar *  target,
gint  len
 

Escape undesirable characters using xx, where xx is an hex code.

This is done in the `target' buffer, whose size is `len'.

Returns:
amount of characters written into buffer (not counting trailing NUL), or -1 if the buffer was too small.

gchar* url_escape_query const gchar *  url  ) 
 

Same as url_escape(), but '+' are also escaped for the query string.

Returns:
argument if no escaping is necessary, or a new string otherwise.

gchar* url_normalize gchar *  url,
url_policy_t  pol
 

Attention:
NB: May modify ``url'' in all cased; pass a copy if necessary!

Returns:
NULL if ``url'' isn't a valid resp. allowed URL. Otherwise, it returns either a pointer to the original URL or a g_malloc()ed modified copy which has to be g_free()ed.
The URL is validated according to the specified policy. Unnecessary parts such as ":80" (for the port) and "/./" are removed: the hostname is forced to lowercase; a base URI "/" is appended if missing. This allows comparing different variants of the same URL to detect duplicates.

void url_params_free url_params_t up  ) 
 

Dispose of the url_params_t structure.

const gchar* url_params_get url_params_t up,
const gchar *  name
 

Get the value of a parameter, or NULL if the parameter is not present.

The value returned has already been URL-unescaped.

url_params_t* url_params_parse gchar *  query  ) 
 

Parse all the parameters in the URL query string.

All parameter values are stored in their URL-unescaped form, but parameter names are NOT un-escaped.

Returns:
an url_params_t object that can be queried for later... or NULL if the argument isn't valid encoded.

gchar* url_unescape gchar *  url,
gboolean  inplace
 

Unescape string, in-place if `inplace' is TRUE.

Returns the argument if un-escaping is NOT necessary, a new string otherwise unless in-place decoding was requested.

Returns:
NULL if the argument isn't valid encoded.


Generated on Sun Feb 12 10:50:09 2006 for Gtk-Gnutella by doxygen 1.3.6