Re: location of bonobo-stream-fs,[ch]
- From: Dietmar Maurer <dietmar maurer-it com>
- To: Michael Meeks <mmeeks gnu org>, "gnome-components-list gnome org" <gnome-components-list gnome org>
- Subject: Re: location of bonobo-stream-fs,[ch]
- Date: Tue, 17 Oct 2000 14:39:08 +0200
Hello Michael,
this patch permits us to move bonobo-stream-fs.[ch] into the
storage-modules subdir.
I would also remove the following files:
remove the file: bonobo/bonobo-storage-driver.h
remove the file: bonobo/bonobo-storage-private.h
remove the file: bonobo/bonobo-storage-priv.h
If you move bonobo-stream-fs.[ch] I can do the rest.
- Dietmar
? bonobo/bonobo-storage-plugin.c
? bonobo/bonobo-storage-plugin.h
Index: bonobo/Makefile.am
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/Makefile.am,v
retrieving revision 1.125
diff -u -r1.125 Makefile.am
--- bonobo/Makefile.am 2000/10/16 17:23:39 1.125
+++ bonobo/Makefile.am 2000/10/17 12:24:03
@@ -1,6 +1,8 @@
+PLUGIN_DIR=$(libdir)/bonobo/plugin
+
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- -DSTORAGE_LIB=\""$(libdir)"\" \
+ -DPLUGIN_DIR=\""$(PLUGIN_DIR)"\" \
-DG_LOG_DOMAIN=\"Bonobo\" \
-I. \
-I$(srcdir) -I$(top_srcdir) \
@@ -62,10 +64,10 @@
bonobo-persist.c \
bonobo-progressive.c \
bonobo-property-listener.c \
+ bonobo-storage-plugin.c \
bonobo-storage.c \
bonobo-stream.c \
bonobo-stream-client.c \
- bonobo-stream-fs.c \
bonobo-stream-memory.c \
bonobo-transient.c \
bonobo-property.c \
@@ -111,9 +113,9 @@
bonobo-property.h \
bonobo-selector.h \
bonobo-socket.h \
+ bonobo-storage-plugin.h \
bonobo-storage.h \
bonobo-stream-client.h \
- bonobo-stream-fs.h \
bonobo-stream-memory.h \
bonobo-stream.h \
bonobo-transient.h \
Index: bonobo/bonobo-file-moniker.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-file-moniker.c,v
retrieving revision 1.30
diff -u -r1.30 bonobo-file-moniker.c
--- bonobo/bonobo-file-moniker.c 2000/07/12 17:11:00 1.30
+++ bonobo/bonobo-file-moniker.c 2000/10/17 12:24:03
@@ -43,7 +43,7 @@
#include <gtk/gtksignal.h>
#include <gtk/gtkmarshal.h>
#include <bonobo/bonobo-file-moniker.h>
-#include <bonobo/bonobo-stream-fs.h>
+#include <bonobo/bonobo-stream.h>
#include <bonobo/bonobo-moniker-client.h>
#include <sys/stat.h>
@@ -189,7 +189,7 @@
if (!persist)
rtn = CORBA_OBJECT_NIL;
else {
- stream = bonobo_stream_fs_open (
+ stream = bonobo_stream_open (
fm->filename, Bonobo_Storage_READ);
if (!stream)
rtn = CORBA_OBJECT_NIL;
Index: bonobo/bonobo-storage.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-storage.c,v
retrieving revision 1.37
diff -u -r1.37 bonobo-storage.c
--- bonobo/bonobo-storage.c 2000/07/05 20:10:13 1.37
+++ bonobo/bonobo-storage.c 2000/10/17 12:24:03
@@ -10,6 +10,7 @@
#include <config.h>
#include <gmodule.h>
#include <bonobo/bonobo-storage.h>
+#include <bonobo/bonobo-storage-plugin.h>
static BonoboObjectClass *bonobo_storage_parent_class;
@@ -232,72 +233,33 @@
return storage;
}
-typedef BonoboStorage * (*driver_open_t)(const char *path, gint flags, gint mode);
-
-static driver_open_t
-load_storage_driver (const char *driver_name)
-{
- GModule *m;
- char *path;
- gpointer driver;
-
- path = g_module_build_path (STORAGE_LIB, driver_name);
- m = g_module_open (path, G_MODULE_BIND_LAZY);
- g_free (path);
-
- if (m == NULL){
- g_free (path);
- return NULL;
- }
-
- if (g_module_symbol (m, "bonobo_storage_driver_open", &driver))
- return driver;
- else
- return NULL;
-}
-
/**
* bonobo_storage_open:
* @driver: driver to use for opening.
* @path: path where the base file resides
- * @flags: Unix open(2) flags
+ * @flags: Bonobo Storage OpenMode
* @mode: Unix open(2) mode
*
* Opens or creates the file named at @path with the stream driver @driver.
*
- * @driver is one of: "efs" or "fs" for now.
+ * @driver is one of: "efs", "vfs" or "fs" for now.
*
* Returns: a created BonoboStorage object.
*/
BonoboStorage *
-bonobo_storage_open (const char *driver, const char *path, gint flags, gint mode)
+bonobo_storage_open (const char *driver, const char *path, gint flags,
+ gint mode)
{
- static driver_open_t fs_driver, efs_driver, vfs_driver;
- driver_open_t *driver_ptr = NULL;
-
+ StoragePlugin *p;
+
+ g_return_val_if_fail (driver != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
-
- if (strcmp (driver, "fs") == 0){
- if (fs_driver == NULL)
- fs_driver = load_storage_driver ("storage_fs");
- driver_ptr = &fs_driver;
- } else if (strcmp (driver, "efs") == 0){
- if (efs_driver == NULL)
- efs_driver = load_storage_driver ("storage_efs");
- driver_ptr = &efs_driver;
- } else if (strcmp (driver, "vfs") == 0) {
- if (vfs_driver == NULL)
- vfs_driver = load_storage_driver ("storage_vfs");
- driver_ptr = &vfs_driver;
- } else {
- g_warning ("Unknown driver `%s' specified", driver);
- return NULL;
- }
+
+ if (!(p = bonobo_storage_plugin_find (driver))) return NULL;
- if (*driver_ptr == NULL)
- return NULL;
+ if (p->storage_open) return p->storage_open (path, flags, mode);
- return (*driver_ptr) (path, flags, mode);
+ return NULL;
}
/**
Index: bonobo/bonobo-storage.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-storage.h,v
retrieving revision 1.25
diff -u -r1.25 bonobo-storage.h
--- bonobo/bonobo-storage.h 2000/07/05 20:10:13 1.25
+++ bonobo/bonobo-storage.h 2000/10/17 12:24:03
@@ -60,13 +60,6 @@
BonoboStorage *bonobo_storage_construct (BonoboStorage *storage,
Bonobo_Storage corba_storage);
-/* Open modes [ flags ] */
-#define BONOBO_SS_READ 1
-#define BONOBO_SS_WRITE 2
-#define BONOBO_SS_RDWR 3
-#define BONOBO_SS_CREATE 4
-#define BONOBO_SS_EXCL 8
-
BonoboStorage *bonobo_storage_open (const char *driver,
const char *path,
gint flags,
@@ -74,17 +67,6 @@
Bonobo_Storage bonobo_storage_corba_object_create (BonoboObject *object);
-/*
- * Functions to open storages and streams from and existing.
- * Storage
- */
-BonoboStorage *bonobo_storage_storage_open (BonoboStorage *storage,
- const char *path,
- const char *open_mode);
-BonoboStream *bonobo_stream_storage_open (BonoboStorage *storage,
- const char *path,
- const char *open_mode);
-
void bonobo_storage_write_class_id (BonoboStorage *storage,
char *class_id);
@@ -93,10 +75,6 @@
POA_Bonobo_Storage__epv *bonobo_storage_get_epv (void);
-/*
- * Signature for Storage drivers
- */
-BonoboStorage *bonobo_storage_driver_open (const char *path, gint flags, gint mode);
END_GNOME_DECLS
Index: bonobo/bonobo-stream.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-stream.c,v
retrieving revision 1.23
diff -u -r1.23 bonobo-stream.c
--- bonobo/bonobo-stream.c 2000/07/06 17:12:21 1.23
+++ bonobo/bonobo-stream.c 2000/10/17 12:24:03
@@ -8,6 +8,7 @@
*/
#include <config.h>
#include <bonobo/bonobo-stream.h>
+#include <bonobo/bonobo-storage-plugin.h>
static BonoboObjectClass *bonobo_stream_parent_class;
@@ -173,6 +174,35 @@
}
return type;
+}
+
+/**
+ * bonobo_stream_open:
+ * @driver: driver to use for opening.
+ * @path: path where the base file resides
+ * @flags: Bonobo Storage OpenMode
+ * @mode: Unix open(2) mode
+ *
+ * Opens or creates the file named at @path with the stream driver @driver.
+ *
+ * @driver is one of: "fs" or "vfs" for now.
+ *
+ * Returns: a created BonoboStream object.
+ */
+BonoboStream *
+bonobo_stream_open (const char *driver, const char *path, gint flags,
+ gint mode)
+{
+ StoragePlugin *p;
+
+ g_return_val_if_fail (driver != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ if (!(p = bonobo_storage_plugin_find (driver))) return NULL;
+
+ if (p->stream_open) return p->stream_open (path, flags, mode);
+
+ return NULL;
}
/**
Index: bonobo/bonobo-stream.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-stream.h,v
retrieving revision 1.16
diff -u -r1.16 bonobo-stream.h
--- bonobo/bonobo-stream.h 2000/07/04 19:18:41 1.16
+++ bonobo/bonobo-stream.h 2000/10/17 12:24:03
@@ -54,6 +54,11 @@
POA_Bonobo_Stream__epv *bonobo_stream_get_epv (void);
Bonobo_Stream bonobo_stream_corba_object_create (BonoboObject *object);
+BonoboStream *bonobo_stream_open (const char *driver,
+ const char *path,
+ gint flags,
+ gint mode);
+
END_GNOME_DECLS
? storage-modules/bonobo-stream-fs.c
? storage-modules/bonobo-stream-fs.h
Index: storage-modules/Makefile.am
===================================================================
RCS file: /cvs/gnome/bonobo/storage-modules/Makefile.am,v
retrieving revision 1.10
diff -u -r1.10 Makefile.am
--- storage-modules/Makefile.am 2000/10/11 17:07:17 1.10
+++ storage-modules/Makefile.am 2000/10/17 12:24:12
@@ -1,8 +1,10 @@
+PLUGIN_DIR=$(libdir)/bonobo/plugin
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(srcdir) -I$(top_srcdir) \
-I$(top_builddir) \
+ -DPLUGIN_DIR=\""$(PLUGIN_DIR)"\" \
-I$(top_srcdir)/libefs/src \
-I$(includedir) \
$(VFS_CFLAGS) \
@@ -10,6 +12,8 @@
common_ldflags = -avoid-version
+bonobo_plugindir = $(PLUGIN_DIR)
+bonobo_plugin_LTLIBRARIES = libstorage_efs.la libstorage_fs.la
#
# EFS storage module
@@ -30,7 +34,9 @@
#
libstorage_fs_la_SOURCES = \
bonobo-storage-fs.c \
- bonobo-storage-fs.h
+ bonobo-storage-fs.h \
+ bonobo-stream-fs.c \
+ bonobo-stream-fs.h
libstorage_fs_la_LDFLAGS = \
$(common_ldflags)
@@ -39,7 +45,7 @@
# VFS storage module - disabled for now.
#
if HAVE_VFS
-libstoragedir = $(libdir)
+libstoragedir = $(PLUGIN_DIR)
libstorage_LTLIBRARIES = \
libstorage_vfs.la
@@ -53,6 +59,3 @@
$(VFS_LIBS)
endif
-lib_LTLIBRARIES = \
- libstorage_fs.la \
- libstorage_efs.la
Index: storage-modules/bonobo-storage-efs.c
===================================================================
RCS file: /cvs/gnome/bonobo/storage-modules/bonobo-storage-efs.c,v
retrieving revision 1.18
diff -u -r1.18 bonobo-storage-efs.c
--- storage-modules/bonobo-storage-efs.c 2000/10/11 17:07:17 1.18
+++ storage-modules/bonobo-storage-efs.c 2000/10/17 12:24:12
@@ -21,6 +21,7 @@
#include <efs.h>
#include <storage-modules/bonobo-storage-efs.h>
#include <storage-modules/bonobo-stream-efs.h>
+#include <bonobo/bonobo-storage-plugin.h>
/*
* Creates and activates the corba server
@@ -261,10 +262,20 @@
bonobo_storage_efs_open (const gchar *path, gint flags, gint mode)
{
BonoboStorageEFS *sefs;
+ gint efs_flags = 0;
+
+ if (flags & Bonobo_Storage_READ)
+ efs_flags |= EFS_READ;
+ if (flags & Bonobo_Storage_WRITE)
+ efs_flags |= EFS_WRITE;
+ if (flags & Bonobo_Storage_CREATE)
+ efs_flags |= EFS_CREATE;
+ if (flags & Bonobo_Storage_FAILIFEXIST)
+ efs_flags |= EFS_EXCL;
sefs = gtk_type_new (bonobo_storage_efs_get_type ());
- if (efs_open (&sefs->dir, path, flags, mode, NULL)) {
+ if (efs_open (&sefs->dir, path, efs_flags, mode, NULL)) {
bonobo_object_unref (BONOBO_OBJECT (sefs));
return NULL;
}
@@ -277,25 +288,16 @@
return BONOBO_STORAGE (sefs);
}
-/*
- * Shared library entry point
- */
-BonoboStorage *
-bonobo_storage_driver_open (const gchar *path, gint flags, gint mode)
+gint
+init_storage_plugin (StoragePlugin *plugin)
{
- gint efs_flags = 0;
+ g_return_val_if_fail (plugin != NULL, -1);
- if (flags & BONOBO_SS_READ)
- efs_flags |= EFS_READ;
- if (flags & BONOBO_SS_WRITE)
- efs_flags |= EFS_WRITE;
- if (flags & BONOBO_SS_RDWR)
- efs_flags |= EFS_RDWR;
- if (flags & BONOBO_SS_CREATE)
- efs_flags |= EFS_CREATE;
- if (flags & BONOBO_SS_EXCL)
- efs_flags |= EFS_EXCL;
+ plugin->name = "efs";
+ plugin->description = "Embedded Filesystem Driver";
+ plugin->version = VERSION;
- return bonobo_storage_efs_open (path, efs_flags, mode);
-}
+ plugin->storage_open = bonobo_storage_efs_open;
+ return 0;
+}
Index: storage-modules/bonobo-storage-fs.c
===================================================================
RCS file: /cvs/gnome/bonobo/storage-modules/bonobo-storage-fs.c,v
retrieving revision 1.21
diff -u -r1.21 bonobo-storage-fs.c
--- storage-modules/bonobo-storage-fs.c 2000/10/11 17:07:17 1.21
+++ storage-modules/bonobo-storage-fs.c 2000/10/17 12:24:12
@@ -15,6 +15,7 @@
#include <libgnome/gnome-util.h>
#include <storage-modules/bonobo-storage-fs.h>
#include <bonobo/bonobo-stream-fs.h>
+#include <bonobo/bonobo-storage-plugin.h>
static BonoboStorageClass *bonobo_storage_fs_parent_class;
@@ -194,23 +195,23 @@
g_return_val_if_fail (path != NULL, NULL);
- if (flags & BONOBO_SS_CREATE){
- if (mkdir (path, mode) == -1){
+ if (flags & Bonobo_Storage_CREATE) {
+ if (mkdir (path, mode) == -1) {
return NULL;
}
}
v = stat (path, &s);
- if (flags & BONOBO_SS_READ){
+ if (flags & Bonobo_Storage_READ) {
if (v == -1)
return NULL;
if (!S_ISDIR (s.st_mode))
return NULL;
- } else if (flags & (BONOBO_SS_RDWR|BONOBO_SS_WRITE)){
- if (v == -1){
+ } else if (flags & Bonobo_Storage_WRITE) {
+ if (v == -1) {
if (mkdir (path, 0777) == -1)
return NULL;
} else {
@@ -222,12 +223,18 @@
return do_bonobo_storage_fs_create (path);
}
-/*
- * Shared library entry point
- */
-BonoboStorage *
-bonobo_storage_driver_open (const char *path, gint flags, gint mode)
+gint
+init_storage_plugin (StoragePlugin *plugin)
{
- return bonobo_storage_fs_open (path, flags, mode);
+ g_return_val_if_fail (plugin != NULL, -1);
+
+ plugin->name = "fs";
+ plugin->description = "Native Filesystem Driver";
+ plugin->version = VERSION;
+
+ plugin->storage_open = bonobo_storage_fs_open;
+ plugin->stream_open = bonobo_stream_fs_open;
+
+ return 0;
}
Index: tests//test-container-autoload.c
===================================================================
RCS file: /cvs/gnome/bonobo/tests/test-container-autoload.c,v
retrieving revision 1.33
diff -u -r1.33 test-container-autoload.c
--- tests//test-container-autoload.c 2000/09/23 14:20:02 1.33
+++ tests//test-container-autoload.c 2000/10/17 12:24:19
@@ -115,7 +115,8 @@
gchar *filename = gtk_file_selection_get_filename (fs);
BonoboStream *stream
- = bonobo_stream_fs_open (filename, Bonobo_Storage_READ);
+ = bonobo_stream_open ("fs", filename,
+ Bonobo_Storage_READ, 0644);
Bonobo_Stream stream_obj =
(Bonobo_Stream) bonobo_object_corba_objref (BONOBO_OBJECT (stream));
Index: tests//test-container.c
===================================================================
RCS file: /cvs/gnome/bonobo/tests/test-container.c,v
retrieving revision 1.66
diff -u -r1.66 test-container.c
--- tests//test-container.c 2000/10/11 14:37:02 1.66
+++ tests//test-container.c 2000/10/17 12:24:19
@@ -337,7 +337,8 @@
printf ("Good: Embeddable supports PersistStream\n");
- stream = bonobo_stream_fs_open ("/tmp/a.png", Bonobo_Storage_READ);
+ stream = bonobo_stream_open ("fs", "/tmp/a.png",
+ Bonobo_Storage_READ, 0664);
if (stream == NULL) {
printf ("I could not open /tmp/a.png!\n");
@@ -379,7 +380,8 @@
printf ("Good: Embeddable supports PersistStream\n");
- stream = bonobo_stream_fs_open ("/tmp/a.pdf", Bonobo_Storage_READ);
+ stream = bonobo_stream_open ("fs", "/tmp/a.pdf",
+ Bonobo_Storage_READ, 0644);
if (stream == NULL){
printf ("I could not open /tmp/a.pdf!\n");
@@ -615,7 +617,8 @@
printf ("Good: Control supports PersistStream\n");
- stream = bonobo_stream_fs_open ("/etc/passwd", Bonobo_Storage_READ);
+ stream = bonobo_stream_open ("fs", "/etc/passwd",
+ Bonobo_Storage_READ, 0644);
if (stream == NULL){
printf ("I could not open /etc/passwd!\n");
Index: tests//test-storage.c
===================================================================
RCS file: /cvs/gnome/bonobo/tests/test-storage.c,v
retrieving revision 1.9
diff -u -r1.9 test-storage.c
--- tests//test-storage.c 2000/08/24 11:25:09 1.9
+++ tests//test-storage.c 2000/10/17 12:24:19
@@ -35,7 +35,8 @@
g_error (_("Can not bonobo_init"));
unlink (file);
- storage = bonobo_storage_open("efs", file, BONOBO_SS_RDWR|BONOBO_SS_CREATE, 0664);
+ storage = bonobo_storage_open("efs", file, Bonobo_Storage_WRITE|
+ Bonobo_Storage_CREATE, 0664);
if (storage == NULL)
g_error ("Could not create storage file %s", file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]