/* GNet - Networking library
 * Copyright (C) 2000-2001  David Helder, David Bolcsfoldi
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 */


#ifndef _GNET_URI_H
#define _GNET_URI_H

#include <glib.h>

/**
 *  GURI:
 *  @scheme: Scheme (or protocol)
 *  @userinfo: User info
 *  @hostname: Host name
 *  @port: Port number
 *  @path: Path
 *  @query: Query
 *  @fragment: Fragment
 *
 *  The #GURI structure represents a URI.  All fields in this
 *  structure are publicly readable.
 *
 **/
typedef struct _GURI GURI;

struct _GURI
{
    gchar* scheme;
    gchar* userinfo;
    gchar* hostname;
    gint   port;
    gchar* path;
    gchar* query;
    gchar* fragment;
};



GURI*
bmp_uri_new (const gchar* uri);
GURI*
bmp_uri_new_fields (const gchar* scheme, const gchar* hostname, 
		     const gint port, const gchar* path);
GURI*
bmp_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);
GURI*
bmp_uri_clone (const GURI* uri);
void
bmp_uri_delete (GURI* uri);

gboolean
bmp_uri_equal (gconstpointer p1, gconstpointer p2);
guint
bmp_uri_hash (gconstpointer p);

void
bmp_uri_escape (GURI* uri);
void
bmp_uri_unescape (GURI* uri);

gchar*
bmp_uri_get_string (const GURI* uri);

void
bmp_uri_set_scheme (GURI* uri, const gchar* scheme);
void
bmp_uri_set_userinfo (GURI* uri, const gchar* userinfo);
void
bmp_uri_set_hostname (GURI* uri, const gchar* hostname);
void
bmp_uri_set_port (GURI* uri, gint port);
void
bmp_uri_set_path (GURI* uri, const gchar* path);
void
bmp_uri_set_query (GURI* uri, const gchar* query);
void
bmp_uri_set_fragment (GURI* uri, const gchar* fragment);

#define PROTOCOL_HTTP "http"
#define PROTOCOL_FILE "file"
#define PROTOCOL_FTP  "ftp"

typedef enum {
    G_URI_TEST_PROTOCOL,
    G_URI_TEST_PORT,
    G_URI_TEST_HOSTNAME,
    G_URI_TEST_PATH,
} GURITest;

gboolean
g_uri_test (const gchar *uri, GURITest test, gpointer compare);

#define G_URI_IS_LOCAL(uri) (g_uri_test (uri, G_URI_TEST_PROTOCOL, PROTOCOL_FILE)) 

#endif /* _GNET_URI_H */
