1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Copyright 1999-2002 Ximian, Inc.
5 */
6
7
8#ifndef __SOUP_URI_H__
9#define __SOUP_URI_H__ 1
10
11#include <libsoup/soup-types.h>
12#include <libsoup/soup-misc.h>
13
14G_BEGIN_DECLS
15
16struct _SoupURI {
17 const char *scheme;
18
19 char *user;
20 char *password;
21
22 char *host;
23 guint port;
24
25 char *path;
26 char *query;
27
28 char *fragment;
29};
30
31SOUP_AVAILABLE_IN_2_4
32GType soup_uri_get_type (void);
33#define SOUP_TYPE_URI (soup_uri_get_type ())
34
35#define SOUP_URI_SCHEME_HTTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http")
36#define SOUP_URI_SCHEME_HTTPS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "https")
37#define SOUP_URI_SCHEME_FTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FTP, "ftp")
38#define SOUP_URI_SCHEME_FILE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FILE, "file")
39#define SOUP_URI_SCHEME_DATA _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_DATA, "data")
40#define SOUP_URI_SCHEME_RESOURCE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_RESOURCE, "resource")
41#define SOUP_URI_SCHEME_WS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WS, "ws")
42#define SOUP_URI_SCHEME_WSS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WSS, "wss")
43
44SOUP_VAR gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
45SOUP_VAR gpointer _SOUP_URI_SCHEME_FTP;
46SOUP_VAR gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA, _SOUP_URI_SCHEME_RESOURCE;
47SOUP_VAR gpointer _SOUP_URI_SCHEME_WS, _SOUP_URI_SCHEME_WSS;
48
49SOUP_AVAILABLE_IN_2_4
50SoupURI *soup_uri_new_with_base (SoupURI *base,
51 const char *uri_string);
52SOUP_AVAILABLE_IN_2_4
53SoupURI *soup_uri_new (const char *uri_string);
54
55SOUP_AVAILABLE_IN_2_4
56char *soup_uri_to_string (SoupURI *uri,
57 gboolean just_path_and_query);
58
59SOUP_AVAILABLE_IN_2_4
60SoupURI *soup_uri_copy (SoupURI *uri);
61
62SOUP_AVAILABLE_IN_2_4
63gboolean soup_uri_equal (SoupURI *uri1,
64 SoupURI *uri2);
65
66SOUP_AVAILABLE_IN_2_4
67void soup_uri_free (SoupURI *uri);
68
69SOUP_AVAILABLE_IN_2_4
70char *soup_uri_encode (const char *part,
71 const char *escape_extra);
72SOUP_AVAILABLE_IN_2_4
73char *soup_uri_decode (const char *part);
74SOUP_AVAILABLE_IN_2_4
75char *soup_uri_normalize (const char *part,
76 const char *unescape_extra);
77
78SOUP_AVAILABLE_IN_2_4
79gboolean soup_uri_uses_default_port (SoupURI *uri);
80
81SOUP_AVAILABLE_IN_2_32
82const char *soup_uri_get_scheme (SoupURI *uri);
83SOUP_AVAILABLE_IN_2_4
84void soup_uri_set_scheme (SoupURI *uri,
85 const char *scheme);
86SOUP_AVAILABLE_IN_2_32
87const char *soup_uri_get_user (SoupURI *uri);
88SOUP_AVAILABLE_IN_2_4
89void soup_uri_set_user (SoupURI *uri,
90 const char *user);
91SOUP_AVAILABLE_IN_2_32
92const char *soup_uri_get_password (SoupURI *uri);
93SOUP_AVAILABLE_IN_2_4
94void soup_uri_set_password (SoupURI *uri,
95 const char *password);
96SOUP_AVAILABLE_IN_2_32
97const char *soup_uri_get_host (SoupURI *uri);
98SOUP_AVAILABLE_IN_2_4
99void soup_uri_set_host (SoupURI *uri,
100 const char *host);
101SOUP_AVAILABLE_IN_2_32
102guint soup_uri_get_port (SoupURI *uri);
103SOUP_AVAILABLE_IN_2_4
104void soup_uri_set_port (SoupURI *uri,
105 guint port);
106SOUP_AVAILABLE_IN_2_32
107const char *soup_uri_get_path (SoupURI *uri);
108SOUP_AVAILABLE_IN_2_4
109void soup_uri_set_path (SoupURI *uri,
110 const char *path);
111SOUP_AVAILABLE_IN_2_32
112const char *soup_uri_get_query (SoupURI *uri);
113SOUP_AVAILABLE_IN_2_4
114void soup_uri_set_query (SoupURI *uri,
115 const char *query);
116SOUP_AVAILABLE_IN_2_4
117void soup_uri_set_query_from_form (SoupURI *uri,
118 GHashTable *form);
119SOUP_AVAILABLE_IN_2_4
120void soup_uri_set_query_from_fields (SoupURI *uri,
121 const char *first_field,
122 ...) G_GNUC_NULL_TERMINATED;
123SOUP_AVAILABLE_IN_2_32
124const char *soup_uri_get_fragment (SoupURI *uri);
125SOUP_AVAILABLE_IN_2_4
126void soup_uri_set_fragment (SoupURI *uri,
127 const char *fragment);
128
129SOUP_AVAILABLE_IN_2_28
130SoupURI *soup_uri_copy_host (SoupURI *uri);
131SOUP_AVAILABLE_IN_2_28
132guint soup_uri_host_hash (gconstpointer key);
133SOUP_AVAILABLE_IN_2_28
134gboolean soup_uri_host_equal (gconstpointer v1,
135 gconstpointer v2);
136
137#define SOUP_URI_IS_VALID(uri) ((uri) && (uri)->scheme && (uri)->path)
138#define SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
139
140G_END_DECLS
141
142#endif /* __SOUP_URI_H__ */
143