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-method.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gnome-vfs-method.h - Virtual class for access methods in the GNOME
3    Virtual File System.
4
5    Copyright (C) 1999, 2001 Free Software Foundation
6
7    The Gnome Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11
12    The Gnome Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Library General Public
18    License along with the Gnome Library; see the file COPYING.LIB.  If not,
19    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.
21
22    Author: Ettore Perazzoli <ettore@comm2000.it> 
23            Seth Nickell <snickell@stanford.edu>
24 */
25
26 #ifndef GNOME_VFS_METHOD_H
27 #define GNOME_VFS_METHOD_H
28
29 /*
30  * The following include helps Solaris copy with its own headers.  (With 64-
31  * bit stuff enabled they like to #define open open64, etc.)
32  * See http://bugzilla.gnome.org/show_bug.cgi?id=71184 for details.
33  */
34 #include <unistd.h>
35
36 #include <libgnomevfs/gnome-vfs-context.h>
37 #include <libgnomevfs/gnome-vfs-file-info.h>
38 #include <libgnomevfs/gnome-vfs-find-directory.h>
39 #include <libgnomevfs/gnome-vfs-handle.h>
40 #include <libgnomevfs/gnome-vfs-transform.h>
41 #include <libgnomevfs/gnome-vfs-monitor.h>
42
43 G_BEGIN_DECLS
44
45 #define _GNOME_VFS_METHOD_PARAM_CHECK(expression)                       \
46         g_return_val_if_fail ((expression), GNOME_VFS_ERROR_BAD_PARAMETERS);
47
48 typedef struct GnomeVFSMethod GnomeVFSMethod;
49
50 typedef GnomeVFSMethod * (* GnomeVFSMethodInitFunc)(const char *method_name, const char *config_args);
51 typedef void (*GnomeVFSMethodShutdownFunc)(GnomeVFSMethod *method);
52
53 typedef GnomeVFSResult (* GnomeVFSMethodOpenFunc)
54                                         (GnomeVFSMethod *method,
55                                          GnomeVFSMethodHandle
56                                         **method_handle_return,
57                                          GnomeVFSURI *uri,
58                                          GnomeVFSOpenMode mode,
59                                          GnomeVFSContext *context);
60
61 typedef GnomeVFSResult (* GnomeVFSMethodCreateFunc)
62                                         (GnomeVFSMethod *method,
63                                          GnomeVFSMethodHandle
64                                         **method_handle_return,
65                                          GnomeVFSURI *uri,
66                                          GnomeVFSOpenMode mode,
67                                          gboolean exclusive,
68                                          guint perm,
69                                          GnomeVFSContext *context);
70
71 typedef GnomeVFSResult (* GnomeVFSMethodCloseFunc)
72                                         (GnomeVFSMethod *method,
73                                          GnomeVFSMethodHandle *method_handle,
74                                          GnomeVFSContext *context);
75
76 typedef GnomeVFSResult (* GnomeVFSMethodReadFunc)
77                                         (GnomeVFSMethod *method,
78                                          GnomeVFSMethodHandle *method_handle,
79                                          gpointer buffer,
80                                          GnomeVFSFileSize num_bytes,
81                                          GnomeVFSFileSize *bytes_read_return,
82                                          GnomeVFSContext *context);
83
84 typedef GnomeVFSResult (* GnomeVFSMethodWriteFunc)
85                                         (GnomeVFSMethod *method,
86                                          GnomeVFSMethodHandle *method_handle,
87                                          gconstpointer buffer,
88                                          GnomeVFSFileSize num_bytes,
89                                          GnomeVFSFileSize *bytes_written_return,
90                                          GnomeVFSContext *context);
91
92 typedef GnomeVFSResult (* GnomeVFSMethodSeekFunc)
93                                         (GnomeVFSMethod *method,
94                                          GnomeVFSMethodHandle *method_handle,
95                                          GnomeVFSSeekPosition  whence,
96                                          GnomeVFSFileOffset    offset,
97                                          GnomeVFSContext *context);
98
99 typedef GnomeVFSResult (* GnomeVFSMethodTellFunc)
100                                         (GnomeVFSMethod *method,
101                                          GnomeVFSMethodHandle *method_handle,
102                                          GnomeVFSFileOffset *offset_return);
103
104 typedef GnomeVFSResult (* GnomeVFSMethodOpenDirectoryFunc)
105                                         (GnomeVFSMethod *method,
106                                          GnomeVFSMethodHandle **method_handle,
107                                          GnomeVFSURI *uri,
108                                          GnomeVFSFileInfoOptions options,
109                                          GnomeVFSContext *context);
110
111 typedef GnomeVFSResult (* GnomeVFSMethodCloseDirectoryFunc)
112                                         (GnomeVFSMethod *method,
113                                          GnomeVFSMethodHandle *method_handle,
114                                          GnomeVFSContext *context);
115
116 typedef GnomeVFSResult (* GnomeVFSMethodReadDirectoryFunc)
117                                         (GnomeVFSMethod *method,
118                                          GnomeVFSMethodHandle *method_handle,
119                                          GnomeVFSFileInfo *file_info,
120                                          GnomeVFSContext *context);
121
122 typedef GnomeVFSResult (* GnomeVFSMethodGetFileInfoFunc)
123                                         (GnomeVFSMethod *method,
124                                          GnomeVFSURI *uri,
125                                          GnomeVFSFileInfo *file_info,
126                                          GnomeVFSFileInfoOptions options,
127                                          GnomeVFSContext *context);
128
129 typedef GnomeVFSResult (* GnomeVFSMethodGetFileInfoFromHandleFunc)
130                                         (GnomeVFSMethod *method,
131                                          GnomeVFSMethodHandle *method_handle,
132                                          GnomeVFSFileInfo *file_info,
133                                          GnomeVFSFileInfoOptions options,
134                                          GnomeVFSContext *context);
135
136 typedef GnomeVFSResult (* GnomeVFSMethodTruncateFunc) (GnomeVFSMethod *method,
137                                                        GnomeVFSURI *uri,
138                                                        GnomeVFSFileSize length,
139                                                        GnomeVFSContext *context);
140 typedef GnomeVFSResult (* GnomeVFSMethodTruncateHandleFunc) (GnomeVFSMethod *method,
141                                                              GnomeVFSMethodHandle *handle,
142                                                              GnomeVFSFileSize length,
143                                                              GnomeVFSContext *context);
144
145 typedef gboolean       (* GnomeVFSMethodIsLocalFunc)
146                                         (GnomeVFSMethod *method,
147                                          const GnomeVFSURI *uri);
148
149 typedef GnomeVFSResult (* GnomeVFSMethodMakeDirectoryFunc)
150                                         (GnomeVFSMethod *method,
151                                          GnomeVFSURI *uri,
152                                          guint perm,
153                                          GnomeVFSContext *context);
154
155 typedef GnomeVFSResult (* GnomeVFSMethodFindDirectoryFunc)
156                                         (GnomeVFSMethod *method,
157                                          GnomeVFSURI *find_near_uri,
158                                          GnomeVFSFindDirectoryKind kind,
159                                          GnomeVFSURI **result_uri,
160                                          gboolean create_if_needed,
161                                          gboolean find_if_needed,
162                                          guint perm,
163                                          GnomeVFSContext *context);
164
165 typedef GnomeVFSResult (* GnomeVFSMethodRemoveDirectoryFunc)
166                                         (GnomeVFSMethod *method,
167                                          GnomeVFSURI *uri,
168                                          GnomeVFSContext *context);
169
170 typedef GnomeVFSResult (* GnomeVFSMethodMoveFunc)
171                                         (GnomeVFSMethod *method,
172                                          GnomeVFSURI *old_uri,
173                                          GnomeVFSURI *new_uri,
174                                          gboolean force_replace,
175                                          GnomeVFSContext *context);
176
177 typedef GnomeVFSResult (* GnomeVFSMethodUnlinkFunc)
178                                         (GnomeVFSMethod *method,
179                                          GnomeVFSURI *uri,
180                                          GnomeVFSContext *context);
181
182 typedef GnomeVFSResult (* GnomeVFSMethodCheckSameFSFunc)
183                                         (GnomeVFSMethod *method,
184                                          GnomeVFSURI *a,
185                                          GnomeVFSURI *b,
186                                          gboolean *same_fs_return,
187                                          GnomeVFSContext *context);
188
189 typedef GnomeVFSResult (* GnomeVFSMethodSetFileInfo)
190                                         (GnomeVFSMethod *method,
191                                          GnomeVFSURI *a,
192                                          const GnomeVFSFileInfo *info,
193                                          GnomeVFSSetFileInfoMask mask,
194                                          GnomeVFSContext *context);
195
196 typedef GnomeVFSResult (* GnomeVFSMethodCreateSymbolicLinkFunc)
197                                         (GnomeVFSMethod *method,
198                                          GnomeVFSURI *uri,
199                                          const gchar *target_reference,
200                                          GnomeVFSContext *context);
201 typedef GnomeVFSResult (* GnomeVFSMethodMonitorAddFunc)
202                                         (GnomeVFSMethod *method,
203                                          GnomeVFSMethodHandle **method_handle_return,
204                                          GnomeVFSURI *uri,
205                                          GnomeVFSMonitorType monitor_type);
206
207 typedef GnomeVFSResult (* GnomeVFSMethodMonitorCancelFunc)
208                                         (GnomeVFSMethod *method,
209                                          GnomeVFSMethodHandle *handle);
210
211 typedef GnomeVFSResult (* GnomeVFSMethodFileControlFunc)
212                                         (GnomeVFSMethod *method,
213                                          GnomeVFSMethodHandle *method_handle,
214                                          const char *operation,
215                                          gpointer operation_data,
216                                          GnomeVFSContext *context);
217
218 \f
219
220 /* Use this macro to test whether a given function is implemented in
221  * a given GnomeVFSMethod.  Note that it checks the expected size of the structure
222  * prior to testing NULL.
223  */
224  
225 #define VFS_METHOD_HAS_FUNC(method,func) ((((char *)&((method)->func)) - ((char *)(method)) < (method)->method_table_size) && method->func != NULL)
226
227 /* Structure defining an access method.  This is also defined as an
228    opaque type in `gnome-vfs-types.h'.  */
229 struct GnomeVFSMethod {
230         gsize method_table_size;                        /* Used for versioning */
231         GnomeVFSMethodOpenFunc open;
232         GnomeVFSMethodCreateFunc create;
233         GnomeVFSMethodCloseFunc close;
234         GnomeVFSMethodReadFunc read;
235         GnomeVFSMethodWriteFunc write;
236         GnomeVFSMethodSeekFunc seek;
237         GnomeVFSMethodTellFunc tell;
238         GnomeVFSMethodTruncateHandleFunc truncate_handle;
239         GnomeVFSMethodOpenDirectoryFunc open_directory;
240         GnomeVFSMethodCloseDirectoryFunc close_directory;
241         GnomeVFSMethodReadDirectoryFunc read_directory;
242         GnomeVFSMethodGetFileInfoFunc get_file_info;
243         GnomeVFSMethodGetFileInfoFromHandleFunc get_file_info_from_handle;
244         GnomeVFSMethodIsLocalFunc is_local;
245         GnomeVFSMethodMakeDirectoryFunc make_directory;
246         GnomeVFSMethodRemoveDirectoryFunc remove_directory;
247         GnomeVFSMethodMoveFunc move;
248         GnomeVFSMethodUnlinkFunc unlink;
249         GnomeVFSMethodCheckSameFSFunc check_same_fs;
250         GnomeVFSMethodSetFileInfo set_file_info;
251         GnomeVFSMethodTruncateFunc truncate;
252         GnomeVFSMethodFindDirectoryFunc find_directory;
253         GnomeVFSMethodCreateSymbolicLinkFunc create_symbolic_link;
254         GnomeVFSMethodMonitorAddFunc monitor_add;
255         GnomeVFSMethodMonitorCancelFunc monitor_cancel;
256         GnomeVFSMethodFileControlFunc file_control;
257 };
258
259 gboolean           gnome_vfs_method_init   (void);
260 GnomeVFSMethod    *gnome_vfs_method_get    (const gchar *name);
261 GnomeVFSTransform *gnome_vfs_transform_get (const gchar *name);
262
263 G_END_DECLS
264
265 #endif /* GNOME_VFS_METHOD_H */