<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>URI</title> <meta name="generator" content="DocBook XSL Stylesheets V1.72.0"> <link rel="start" href="index.html" title="GNet Network Library Reference Manual"> <link rel="up" href="libgnet-reference.html" title="GNet Library Reference"> <link rel="prev" href="gnet-iochannel.html" title="IOChannel"> <link rel="next" href="gnet-base64.html" title="Base64"> <meta name="generator" content="GTK-Doc V1.8 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> <link rel="chapter" href="gnet-overview.html" title="GNet Overview"> <link rel="chapter" href="gnet-developers.html" title="GNet for developers"> <link rel="chapter" href="gnet-examples.html" title="GNet Examples"> <link rel="chapter" href="libgnet-reference.html" title="GNet Library Reference"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> <tr valign="middle"> <td><a accesskey="p" href="gnet-iochannel.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> <td><a accesskey="u" href="libgnet-reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> <th width="100%" align="center">GNet Network Library Reference Manual</th> <td><a accesskey="n" href="gnet-base64.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> </tr> <tr><td colspan="5" class="shortcuts"><nobr><a href="#id381230" class="shortcut">Top</a>  |  <a href="#id382130" class="shortcut">Description</a></nobr></td></tr> </table> <div class="refentry" lang="en"> <a name="gnet-uri"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2> <a name="id381230"></a><span class="refentrytitle">URI</span> </h2> <p>URI — Uniform Resource Identifier (URI)</p> </td> <td valign="top" align="right"></td> </tr></table></div> <div class="refsynopsisdiv"> <h2>Synopsis</h2> <pre class="synopsis"> #include <gnet.h> <a href="gnet-uri.html#GURI:CAPS">GURI</a>; <a href="gnet-uri.html#GURI:CAPS">GURI</a>* <a href="gnet-uri.html#gnet-uri-new">gnet_uri_new</a> (const gchar *uri); <a href="gnet-uri.html#GURI:CAPS">GURI</a>* <a href="gnet-uri.html#gnet-uri-new-fields">gnet_uri_new_fields</a> (const gchar *scheme, const gchar *hostname, const gint port, const gchar *path); <a href="gnet-uri.html#GURI:CAPS">GURI</a>* <a href="gnet-uri.html#gnet-uri-new-fields-all">gnet_uri_new_fields_all</a> (const gchar *scheme, const gchar *userinfo, const gchar *hostname, const gint port, const gchar *path, const gchar *query, const gchar *fragment); <a href="gnet-uri.html#GURI:CAPS">GURI</a>* <a href="gnet-uri.html#gnet-uri-clone">gnet_uri_clone</a> (const <a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri); void <a href="gnet-uri.html#gnet-uri-delete">gnet_uri_delete</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri); void <a href="gnet-uri.html#gnet-uri-escape">gnet_uri_escape</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri); void <a href="gnet-uri.html#gnet-uri-unescape">gnet_uri_unescape</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri); gchar* <a href="gnet-uri.html#gnet-uri-get-string">gnet_uri_get_string</a> (const <a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri); void <a href="gnet-uri.html#gnet-uri-set-scheme">gnet_uri_set_scheme</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *scheme); void <a href="gnet-uri.html#gnet-uri-set-userinfo">gnet_uri_set_userinfo</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *userinfo); void <a href="gnet-uri.html#gnet-uri-set-hostname">gnet_uri_set_hostname</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *hostname); void <a href="gnet-uri.html#gnet-uri-set-port">gnet_uri_set_port</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, gint port); void <a href="gnet-uri.html#gnet-uri-set-path">gnet_uri_set_path</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *path); void <a href="gnet-uri.html#gnet-uri-set-query">gnet_uri_set_query</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *query); void <a href="gnet-uri.html#gnet-uri-set-fragment">gnet_uri_set_fragment</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *fragment); guint <a href="gnet-uri.html#gnet-uri-hash">gnet_uri_hash</a> (gconstpointer p); gboolean <a href="gnet-uri.html#gnet-uri-equal">gnet_uri_equal</a> (gconstpointer p1, gconstpointer p2); gboolean <a href="gnet-uri.html#gnet-uri-parse-inplace">gnet_uri_parse_inplace</a> (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *guri, gchar *uri, gchar *hostname, gsize len); </pre> </div> <div class="refsect1" lang="en"> <a name="id382130"></a><h2>Description</h2> <p> A URI is a Uniform Resource Identifier, similar to a URL. This module provides functions for creating and manipulating URIs. A URI is represented by <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>. All fields in the <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> structure are publicly readable. </p> <p> Create a URI from a string by calling <a href="gnet-uri.html#gnet-uri-new"><code class="function">gnet_uri_new()</code></a>. To get the string representation back, call <a href="gnet-uri.html#gnet-uri-get-string"><code class="function">gnet_uri_get_string()</code></a>. To escape a URI call <a href="gnet-uri.html#gnet-uri-escape"><code class="function">gnet_uri_escape()</code></a>, and to unescape it call <a href="gnet-uri.html#gnet-uri-unescape"><code class="function">gnet_uri_unescape()</code></a>. Network protocols use escaped URIs. People use unescaped URIs. </p> </div> <div class="refsect1" lang="en"> <a name="id382208"></a><h2>Details</h2> <div class="refsect2" lang="en"> <a name="id382218"></a><h3> <a name="GURI:CAPS"></a>GURI</h3> <a class="indexterm" name="id382230"></a><pre class="programlisting">typedef struct { gchar* scheme; gchar* userinfo; gchar* hostname; gint port; gchar* path; gchar* query; gchar* fragment; } GURI; </pre> <p> The <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> structure represents a URI. All fields in this structure are publicly readable.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term">gchar *<em class="structfield"><code>scheme</code></em>;</span></td> <td> Scheme (or protocol) </td> </tr> <tr> <td><span class="term">gchar *<em class="structfield"><code>userinfo</code></em>;</span></td> <td> User info </td> </tr> <tr> <td><span class="term">gchar *<em class="structfield"><code>hostname</code></em>;</span></td> <td> Host name </td> </tr> <tr> <td><span class="term">gint <em class="structfield"><code>port</code></em>;</span></td> <td> Port number </td> </tr> <tr> <td><span class="term">gchar *<em class="structfield"><code>path</code></em>;</span></td> <td> Path </td> </tr> <tr> <td><span class="term">gchar *<em class="structfield"><code>query</code></em>;</span></td> <td> Query </td> </tr> <tr> <td><span class="term">gchar *<em class="structfield"><code>fragment</code></em>;</span></td> <td> Fragment </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id382404"></a><h3> <a name="gnet-uri-new"></a>gnet_uri_new ()</h3> <a class="indexterm" name="id382416"></a><pre class="programlisting"><a href="gnet-uri.html#GURI:CAPS">GURI</a>* gnet_uri_new (const gchar *uri);</pre> <p> Creates a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> from a string. Empty fields are set to NULL. The parser does not validate the URI -- it will accept some malformed URI. URIs are usually in the form scheme://userinfo<em class="parameter"><code>hostname</code></em>:port/path?query<span class="type">fragment</span> </p> <p> URIs created from user input are typically unescaped. URIs created from machine input (e.g. received over the internet) are typically escaped.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> URI string </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> a new <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>, or NULL if there was a failure. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id382512"></a><h3> <a name="gnet-uri-new-fields"></a>gnet_uri_new_fields ()</h3> <a class="indexterm" name="id382524"></a><pre class="programlisting"><a href="gnet-uri.html#GURI:CAPS">GURI</a>* gnet_uri_new_fields (const gchar *scheme, const gchar *hostname, const gint port, const gchar *path);</pre> <p> Creates a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> from the fields. This function uses the most common fields. Use <a href="gnet-uri.html#gnet-uri-new-fields-all"><code class="function">gnet_uri_new_fields_all()</code></a> to specify all fields.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>scheme</code></em> :</span></td> <td> scheme </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>hostname</code></em> :</span></td> <td> host name </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>port</code></em> :</span></td> <td> port </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>path</code></em> :</span></td> <td> path </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> a new <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id382674"></a><h3> <a name="gnet-uri-new-fields-all"></a>gnet_uri_new_fields_all ()</h3> <a class="indexterm" name="id382686"></a><pre class="programlisting"><a href="gnet-uri.html#GURI:CAPS">GURI</a>* gnet_uri_new_fields_all (const gchar *scheme, const gchar *userinfo, const gchar *hostname, const gint port, const gchar *path, const gchar *query, const gchar *fragment);</pre> <p> Creates a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> from all fields.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>scheme</code></em> :</span></td> <td> scheme </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>userinfo</code></em> :</span></td> <td> user info </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>hostname</code></em> :</span></td> <td> host name </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>port</code></em> :</span></td> <td> port </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>path</code></em> :</span></td> <td> path </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>query</code></em> :</span></td> <td> query </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>fragment</code></em> :</span></td> <td> fragment </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> a new <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id382888"></a><h3> <a name="gnet-uri-clone"></a>gnet_uri_clone ()</h3> <a class="indexterm" name="id382900"></a><pre class="programlisting"><a href="gnet-uri.html#GURI:CAPS">GURI</a>* gnet_uri_clone (const <a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri);</pre> <p> Copies a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> a copy of <em class="parameter"><code>uri</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id382980"></a><h3> <a name="gnet-uri-delete"></a>gnet_uri_delete ()</h3> <a class="indexterm" name="id382993"></a><pre class="programlisting">void gnet_uri_delete (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri);</pre> <p> Deletes a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383057"></a><h3> <a name="gnet-uri-escape"></a>gnet_uri_escape ()</h3> <a class="indexterm" name="id383070"></a><pre class="programlisting">void gnet_uri_escape (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri);</pre> <p> Escapes the fields in a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>. Network protocols use escaped URIs. People use unescaped URIs.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383134"></a><h3> <a name="gnet-uri-unescape"></a>gnet_uri_unescape ()</h3> <a class="indexterm" name="id383147"></a><pre class="programlisting">void gnet_uri_unescape (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri);</pre> <p> Unescapes the fields in the URI. Network protocols use escaped URIs. People use unescaped URIs.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody><tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr></tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383204"></a><h3> <a name="gnet-uri-get-string"></a>gnet_uri_get_string ()</h3> <a class="indexterm" name="id383216"></a><pre class="programlisting">gchar* gnet_uri_get_string (const <a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri);</pre> <p> Gets a string representation of a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>. This function does not escape or unescape the fields first. Call <a href="gnet-uri.html#gnet-uri-escape"><code class="function">gnet_uri_escape()</code></a> or gnet_uri_unescape first if necessary.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> a string. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383302"></a><h3> <a name="gnet-uri-set-scheme"></a>gnet_uri_set_scheme ()</h3> <a class="indexterm" name="id383315"></a><pre class="programlisting">void gnet_uri_set_scheme (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *scheme);</pre> <p> Sets a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s scheme.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>scheme</code></em> :</span></td> <td> scheme </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383400"></a><h3> <a name="gnet-uri-set-userinfo"></a>gnet_uri_set_userinfo ()</h3> <a class="indexterm" name="id383412"></a><pre class="programlisting">void gnet_uri_set_userinfo (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *userinfo);</pre> <p> Sets a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s user info.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>userinfo</code></em> :</span></td> <td> user info </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383498"></a><h3> <a name="gnet-uri-set-hostname"></a>gnet_uri_set_hostname ()</h3> <a class="indexterm" name="id383510"></a><pre class="programlisting">void gnet_uri_set_hostname (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *hostname);</pre> <p> Sets a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s host name.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>hostname</code></em> :</span></td> <td> host name </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383596"></a><h3> <a name="gnet-uri-set-port"></a>gnet_uri_set_port ()</h3> <a class="indexterm" name="id383608"></a><pre class="programlisting">void gnet_uri_set_port (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, gint port);</pre> <p> Set a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s port.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>port</code></em> :</span></td> <td> port </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383693"></a><h3> <a name="gnet-uri-set-path"></a>gnet_uri_set_path ()</h3> <a class="indexterm" name="id383705"></a><pre class="programlisting">void gnet_uri_set_path (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *path);</pre> <p> Set a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s path.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>path</code></em> :</span></td> <td> path </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383791"></a><h3> <a name="gnet-uri-set-query"></a>gnet_uri_set_query ()</h3> <a class="indexterm" name="id383803"></a><pre class="programlisting">void gnet_uri_set_query (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *query);</pre> <p> Set a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s query.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>query</code></em> :</span></td> <td> query </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383889"></a><h3> <a name="gnet-uri-set-fragment"></a>gnet_uri_set_fragment ()</h3> <a class="indexterm" name="id383901"></a><pre class="programlisting">void gnet_uri_set_fragment (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *uri, const gchar *fragment);</pre> <p> Set a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s fragment.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>fragment</code></em> :</span></td> <td> fragment </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id383986"></a><h3> <a name="gnet-uri-hash"></a>gnet_uri_hash ()</h3> <a class="indexterm" name="id383999"></a><pre class="programlisting">guint gnet_uri_hash (gconstpointer p);</pre> <p> Creates a hash code for <em class="parameter"><code>p</code></em> for use with GHashTable.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>p</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> hash code for <em class="parameter"><code>p</code></em>. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id384077"></a><h3> <a name="gnet-uri-equal"></a>gnet_uri_equal ()</h3> <a class="indexterm" name="id384089"></a><pre class="programlisting">gboolean gnet_uri_equal (gconstpointer p1, gconstpointer p2);</pre> <p> Compares two <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a>'s for equality.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>p1</code></em> :</span></td> <td> a <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>p2</code></em> :</span></td> <td> another <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> TRUE if they are equal; FALSE otherwise. </td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2" lang="en"> <a name="id384192"></a><h3> <a name="gnet-uri-parse-inplace"></a>gnet_uri_parse_inplace ()</h3> <a class="indexterm" name="id384207"></a><pre class="programlisting">gboolean gnet_uri_parse_inplace (<a href="gnet-uri.html#GURI:CAPS">GURI</a> *guri, gchar *uri, gchar *hostname, gsize len);</pre> <p> This function parses an URI string very efficiently and without allocating any memory on the heap. It does this by modifying the passed-in string <em class="parameter"><code>uri</code></em> and changing field separators into string terminators in place. The result will then be put into the already-allocated and usually uninitialised, GURI structure <em class="parameter"><code>guri</code></em>. </p> <p> Because the slash (') which separates the hostname from the path in an URI is needed as the first character of the path, it cannot be turned into a string terminator for the hostname. This makes it necessary for the caller (ie. you) to pass in an array where the hostname can be put. </p> <p> If the URI has been parsed successfully, the fields of the GURI structure will either point into the given string <em class="parameter"><code>uri</code></em> (or to <em class="parameter"><code>hostname</code></em> in case of the hostname field), or be NULL. No freeing or de-initialising of the GURI structure is required. </p> <p> The only gnet_uri_*() functions you are allowed to call with this URI structure are <a href="gnet-uri.html#gnet-uri-clone"><code class="function">gnet_uri_clone()</code></a>, <a href="gnet-uri.html#gnet-uri-equal"><code class="function">gnet_uri_equal()</code></a>, <a href="gnet-uri.html#gnet-uri-hash"><code class="function">gnet_uri_hash()</code></a>, <a href="gnet-uri.html#gnet-uri-get-string"><code class="function">gnet_uri_get_string()</code></a> and <a href="gnet-uri.html#gnet-uri-unescape"><code class="function">gnet_uri_unescape()</code></a> (the latter unescapes the string fragments in place, so is safe to use here). </p> <p> You must not call any other gnet_uri_*() functions with this GURI, especially not any <code class="function">gnet_uri_set()</code> functions. </p> <p> Under normal circumstances, you should never need to use this function. Use <a href="gnet-uri.html#gnet-uri-new"><code class="function">gnet_uri_new()</code></a> instead.</p> <p> </p> <div class="variablelist"><table border="0"> <col align="left" valign="top"> <tbody> <tr> <td><span class="term"><em class="parameter"><code>guri</code></em> :</span></td> <td> pointer to an uninitialised <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> structure (usually on the stack) </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>uri</code></em> :</span></td> <td> a writable URI string (which will be modified by this function!) </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>hostname</code></em> :</span></td> <td> a preallocated array of size <em class="parameter"><code>len</code></em>, into which the hostname will be copied if the URI has a hostname. This array should live as long as <em class="parameter"><code>guri</code></em> may be used, since <em class="parameter"><code>guri</code></em> might reference it. You may pass NULL here if you know your URIs won't contain a hostname field </td> </tr> <tr> <td><span class="term"><em class="parameter"><code>len</code></em> :</span></td> <td> </td> </tr> <tr> <td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td> <td> TRUE if <em class="parameter"><code>uri</code></em> was parsed successfully and <a href="gnet-uri.html#GURI:CAPS"><span class="type">GURI</span></a> is usable, or FALSE if there was a failure. </td> </tr> </tbody> </table></div> <p class="since">Since 2.0.8 </p> </div> </div> </div> </body> </html>