ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / libgnomevfs / gnome-vfs-uri.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gnome-vfs-uri.h - URI handling for the GNOME Virtual File System.
3
4    Copyright (C) 1999 Free Software Foundation
5
6    The Gnome Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Library General Public License as
8    published by the Free Software Foundation; either version 2 of the
9    License, or (at your option) any later version.
10
11    The Gnome Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15
16    You should have received a copy of the GNU Library General Public
17    License along with the Gnome Library; see the file COPYING.LIB.  If not,
18    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.
20
21    Author: Ettore Perazzoli <ettore@comm2000.it>
22 */
23
24 #ifndef GNOME_VFS_URI_H
25 #define GNOME_VFS_URI_H
26
27 #include <glib/glist.h>
28
29 G_BEGIN_DECLS
30
31 /* This describes a URI element.  */
32 typedef struct GnomeVFSURI {
33         /* Reference count.  */
34         guint ref_count;
35
36         /* Text for the element: eg. some/path/name.  */
37         gchar *text;
38
39         /* Text for uri fragment: eg, #anchor  */
40         gchar *fragment_id;
41         
42         /* Method string: eg. `gzip', `tar', `http'.  This is necessary as
43            one GnomeVFSMethod can be used for different method strings
44            (e.g. extfs handles zip, rar, zoo and several other ones).  */
45         gchar *method_string;
46
47         /* VFS method to access the element.  */
48         struct GnomeVFSMethod *method;
49
50         /* Pointer to the parent element, or NULL for toplevel elements.  */
51         struct GnomeVFSURI *parent;
52
53         /* Reserved to avoid future breaks in ABI compatibility */
54         void *reserved1;
55         void *reserved2;
56 } GnomeVFSURI;
57
58 /* This is the toplevel URI element.  A toplevel method implementations should
59    cast the `GnomeVFSURI' argument to this type to get the additional host/auth
60    information.  If any of the elements is 0, it is unspecified.  */
61 typedef struct {
62         /* Base object.  */
63         GnomeVFSURI uri;
64
65         /* Server location information.  */
66         gchar *host_name;
67         guint host_port;
68
69         /* Authorization information.  */
70         gchar *user_name;
71         gchar *password;
72
73         /* The parent URN, if it exists */
74         gchar *urn;
75
76         /* Reserved to avoid future breaks in ABI compatibility */
77         void *reserved1;
78         void *reserved2;
79
80 } GnomeVFSToplevelURI;
81
82
83 /**
84  * GnomeVFSURIHideOptions:
85  * @GNOME_VFS_URI_HIDE_NONE: don't hide anything
86  * @GNOME_VFS_URI_HIDE_USER_NAME: hide the user name
87  * @GNOME_VFS_URI_HIDE_PASSWORD: hide the password
88  * @GNOME_VFS_URI_HIDE_HOST_NAME: hide the host name
89  * @GNOME_VFS_URI_HIDE_HOST_PORT: hide the port
90  * @GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD: hide the method (e.g. http, file)
91  * @GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER: hide the fragment identifier
92  *
93  * Packed boolean bitfield controlling hiding of various elements
94  * of a GnomeVFSURI when it is converted to a string.
95  **/
96 typedef enum {
97         GNOME_VFS_URI_HIDE_NONE = 0,
98         GNOME_VFS_URI_HIDE_USER_NAME = 1 << 0,
99         GNOME_VFS_URI_HIDE_PASSWORD = 1 << 1,
100         GNOME_VFS_URI_HIDE_HOST_NAME = 1 << 2,
101         GNOME_VFS_URI_HIDE_HOST_PORT = 1 << 3,
102         GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD = 1 << 4,
103         GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER = 1 << 8
104 } GnomeVFSURIHideOptions;
105
106
107 /**
108  * GNOME_VFS_URI_MAGIC_CHR:
109  *
110  * The character used to divide location from
111  * extra "arguments" passed to the method.
112  **/
113 /**
114  * GNOME_VFS_URI_MAGIC_STR:
115  *
116  * The character used to divide location from
117  * extra "arguments" passed to the method.
118  **/
119 #define GNOME_VFS_URI_MAGIC_CHR '#'
120 #define GNOME_VFS_URI_MAGIC_STR "#"
121
122 /**
123  * GNOME_VFS_URI_PATH_CHR:
124  *
125  * Defines the path seperator character.
126  **/
127 /**
128  * GNOME_VFS_URI_PATH_STR:
129  *
130  * Defines the path seperator string.
131  **/
132 #define GNOME_VFS_URI_PATH_CHR '/'
133 #define GNOME_VFS_URI_PATH_STR "/"
134
135 /* FUNCTIONS */
136 GnomeVFSURI          *gnome_vfs_uri_new                   (const gchar *text_uri);
137 GnomeVFSURI          *gnome_vfs_uri_resolve_relative      (const GnomeVFSURI *base,
138                                                            const gchar *relative_reference);
139 GnomeVFSURI          *gnome_vfs_uri_ref                   (GnomeVFSURI *uri);
140 void                  gnome_vfs_uri_unref                 (GnomeVFSURI *uri);
141
142 GnomeVFSURI          *gnome_vfs_uri_append_string         (const GnomeVFSURI *uri,
143                                                            const char *uri_fragment);
144 GnomeVFSURI          *gnome_vfs_uri_append_path           (const GnomeVFSURI *uri,
145                                                            const char *path);
146 GnomeVFSURI          *gnome_vfs_uri_append_file_name      (const GnomeVFSURI *uri,
147                                                            const gchar *filename);
148 gchar                *gnome_vfs_uri_to_string             (const GnomeVFSURI *uri,
149                                                            GnomeVFSURIHideOptions hide_options);
150 GnomeVFSURI          *gnome_vfs_uri_dup                   (const GnomeVFSURI *uri);
151 gboolean              gnome_vfs_uri_is_local              (const GnomeVFSURI *uri);
152 gboolean              gnome_vfs_uri_has_parent            (const GnomeVFSURI *uri);
153 GnomeVFSURI          *gnome_vfs_uri_get_parent            (const GnomeVFSURI *uri);
154
155 GnomeVFSToplevelURI *gnome_vfs_uri_get_toplevel           (const GnomeVFSURI *uri);
156
157 const gchar         *gnome_vfs_uri_get_host_name          (const GnomeVFSURI *uri);
158 const gchar         *gnome_vfs_uri_get_scheme             (const GnomeVFSURI *uri);
159 guint                gnome_vfs_uri_get_host_port          (const GnomeVFSURI *uri);
160 const gchar         *gnome_vfs_uri_get_user_name          (const GnomeVFSURI *uri);
161 const gchar         *gnome_vfs_uri_get_password           (const GnomeVFSURI *uri);
162
163 void                 gnome_vfs_uri_set_host_name          (GnomeVFSURI *uri,
164                                                            const gchar *host_name);
165 void                 gnome_vfs_uri_set_host_port          (GnomeVFSURI *uri,
166                                                            guint host_port);
167 void                 gnome_vfs_uri_set_user_name          (GnomeVFSURI *uri,
168                                                            const gchar *user_name);
169 void                 gnome_vfs_uri_set_password           (GnomeVFSURI *uri,
170                                                            const gchar *password);
171
172 gboolean             gnome_vfs_uri_equal                  (const GnomeVFSURI *a,
173                                                            const GnomeVFSURI *b);
174
175 gboolean             gnome_vfs_uri_is_parent              (const GnomeVFSURI *possible_parent,
176                                                            const GnomeVFSURI *possible_child,
177                                                            gboolean recursive);
178                                   
179 const gchar         *gnome_vfs_uri_get_path                (const GnomeVFSURI *uri);
180 const gchar         *gnome_vfs_uri_get_fragment_identifier (const GnomeVFSURI *uri);
181 gchar               *gnome_vfs_uri_extract_dirname         (const GnomeVFSURI *uri);
182 gchar               *gnome_vfs_uri_extract_short_name      (const GnomeVFSURI *uri);
183 gchar               *gnome_vfs_uri_extract_short_path_name (const GnomeVFSURI *uri);
184
185 gint                 gnome_vfs_uri_hequal                  (gconstpointer a,
186                                                             gconstpointer b);
187 guint                gnome_vfs_uri_hash                    (gconstpointer p);
188
189 GList               *gnome_vfs_uri_list_parse              (const gchar* uri_list);
190 GList               *gnome_vfs_uri_list_ref                (GList *list);
191 GList               *gnome_vfs_uri_list_unref              (GList *list);
192 GList               *gnome_vfs_uri_list_copy               (GList *list);
193 void                 gnome_vfs_uri_list_free               (GList *list);
194
195 char                *gnome_vfs_uri_make_full_from_relative (const char *base_uri,
196                                                             const char *relative_uri);
197
198 G_END_DECLS
199
200 #endif /* GNOME_VFS_URI_H */