Fix warnings
authorAlexander Larsson <alexl@redhat.com>
Wed, 5 Dec 2007 11:05:49 +0000 (11:05 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Wed, 5 Dec 2007 11:05:49 +0000 (11:05 +0000)
2007-12-05  Alexander Larsson  <alexl@redhat.com>

        * gdatainputstream.c:
Fix warnings

        * gio.symbols:
        * giomodule.[ch]
        * glocaldirectorymonitor.c:
        * glocalfilemonitor.c:
        * gunionvolumemonitor.c:
        * gvfs.c:
Make g_io_modules_ensure_loaded a private function and
don't pass in the dirname. This means we can do magic
directory finding in the win32 version.
Export the actual load-modules-in-directory code so that
gvfs can reuse that.

svn path=/trunk/; revision=6050

gio/ChangeLog
gio/gdatainputstream.c
gio/gio.symbols
gio/giomodule.c
gio/giomodule.h
gio/glocaldirectorymonitor.c
gio/glocalfilemonitor.c
gio/gunionvolumemonitor.c
gio/gvfs.c

index 6b2f1e7..9869395 100644 (file)
@@ -1,5 +1,22 @@
 2007-12-05  Alexander Larsson  <alexl@redhat.com>
 
+        * gdatainputstream.c:
+       Fix warnings
+       
+        * gio.symbols:
+        * giomodule.[ch]
+        * glocaldirectorymonitor.c:
+        * glocalfilemonitor.c:
+        * gunionvolumemonitor.c:
+        * gvfs.c:
+       Make g_io_modules_ensure_loaded a private function and
+       don't pass in the dirname. This means we can do magic
+       directory finding in the win32 version.
+       Export the actual load-modules-in-directory code so that
+       gvfs can reuse that.
+
+2007-12-05  Alexander Larsson  <alexl@redhat.com>
+
         * gbufferedinputstream.c:
         * gbufferedoutputstream.c:
         * gdrive.[ch]:
index b5fdd6a..1130c1c 100644 (file)
@@ -650,7 +650,7 @@ scan_for_newline (GDataInputStream *stream,
   newline_len = 0;
   
   start = checked;
-  buffer = (guint8*)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
+  buffer = (const char*)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
   end = available;
   peeked = end - start;
 
@@ -826,7 +826,7 @@ scan_for_chars (GDataInputStream *stream,
   found_pos = -1;
   
   start = checked;
-  buffer = (guint8*)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
+  buffer = (const char *)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
   end = available;
   peeked = end - start;
 
index db331fa..0102353 100644 (file)
@@ -499,7 +499,7 @@ g_io_error_from_errno
 #if IN_FILE(__G_IO_MODULE_C__)
 g_io_module_get_type  G_GNUC_CONST
 g_io_module_new 
-g_io_modules_ensure_loaded 
+g_io_modules_load_all_in_directory
 #endif
 #endif
 
index 02d12d6..8312d80 100644 (file)
@@ -23,6 +23,7 @@
 #include <config.h>
 
 #include "giomodule.h"
+#include "giomodule-priv.h"
 
 #include "gioalias.h"
 
@@ -31,7 +32,8 @@
  * @short_description: Loadable GIO Modules
  *
  * Provides an interface and default functions for loading and unloading 
- * GIO modules.
+ * modules. This is used internally to make gio extensible, but can also
+ * be used by other to implement module loading.
  * 
  **/
 
@@ -139,9 +141,10 @@ g_io_module_unload_module (GTypeModule *gmodule)
 
 /**
  * g_io_module_new:
- * @filename: filename of the module to load.
+ * @filename: filename of the shared library module.
  * 
- * Loads a new module into GIO.
+ * Creates a new GIOModule that will load the specific
+ * shared library when in use.
  * 
  * Returns: a #GIOModule from given @filename, 
  * or %NULL on error.
@@ -171,8 +174,16 @@ is_valid_module_name (const gchar *basename)
 #endif
 }
 
-static GList *
-load_modules (const char *dirname)
+/**
+ * g_io_modules_load_all_in_directory:
+ * @dirname: pathname for a directory containing modules to load.
+ * 
+ * Loads all the modules in the the specified directory.
+ * 
+ * Returns: a list of #GIOModules loaded from the directory
+ **/
+GList *
+g_io_modules_load_all_in_directory (const char *dirname)
 {
   const gchar *name;
   GDir        *dir;
@@ -218,33 +229,21 @@ load_modules (const char *dirname)
 }
 
 G_LOCK_DEFINE_STATIC (loaded_dirs);
-static GHashTable *loaded_dirs = NULL;
 
-/**
- * g_io_modules_ensure_loaded:
- * @directory: string containing a directory path.
- * 
- * Loads all of the modules within the @directory. 
- **/
 void
-g_io_modules_ensure_loaded (const char *directory)
+_g_io_modules_ensure_loaded (void)
 {
   GList *modules;
+  const char *directory;
+  static gboolean loaded_dirs = FALSE;
 
-  g_return_if_fail (directory != NULL);
   
   G_LOCK (loaded_dirs);
 
-  if (loaded_dirs == NULL)
-    loaded_dirs = g_hash_table_new (g_str_hash, g_str_equal);
-
-  if (!g_hash_table_lookup_extended (loaded_dirs, directory,
-                                    NULL, NULL))
+  if (!loaded_dirs)
     {
-      modules = load_modules (directory);
-      g_hash_table_insert (loaded_dirs,
-                          g_strdup (directory),
-                          modules);
+      loaded_dirs = TRUE;
+      modules = g_io_modules_load_all_in_directory (GIO_MODULE_DIR);
     }
   
   G_UNLOCK (loaded_dirs);
index 031f349..36b6de7 100644 (file)
@@ -46,7 +46,7 @@ typedef struct _GIOModuleClass GIOModuleClass;
 GType      g_io_module_get_type (void) G_GNUC_CONST;
 GIOModule *g_io_module_new      (const gchar *filename);
 
-void       g_io_modules_ensure_loaded (const char *directory);
+GList *    g_io_modules_load_all_in_directory (const char *dirname);
 
 /* API for the modules to implement */
 /**
index b8abf2c..b2c473e 100644 (file)
@@ -222,7 +222,7 @@ get_default_local_directory_monitor (gpointer data)
   _g_inotify_directory_monitor_get_type ();
 #endif
 
-  g_io_modules_ensure_loaded (GIO_MODULE_DIR);
+  _g_io_modules_ensure_loaded ();
   
   monitor_impls = g_type_children (G_TYPE_LOCAL_DIRECTORY_MONITOR,
                                    &n_monitor_impls);
index d083927..1820db9 100644 (file)
@@ -158,7 +158,7 @@ get_default_local_file_monitor (gpointer data)
   _g_inotify_file_monitor_get_type ();
 #endif
 
-  g_io_modules_ensure_loaded (GIO_MODULE_DIR);
+  _g_io_modules_ensure_loaded ();
   
   monitor_impls = g_type_children (G_TYPE_LOCAL_FILE_MONITOR,
                                    &n_monitor_impls);
index 0958963..faaa3c1 100644 (file)
@@ -259,7 +259,7 @@ get_default_native_type (gpointer data)
 #endif
       
   /* Ensure vfs in modules loaded */
-  g_io_modules_ensure_loaded (GIO_MODULE_DIR);
+  _g_io_modules_ensure_loaded ();
       
   monitors = g_type_children (G_TYPE_NATIVE_VOLUME_MONITOR, &n_monitors);
   native_type = 0;
index af4a9dc..8f69191 100644 (file)
@@ -220,7 +220,7 @@ get_default_vfs (gpointer arg)
   local_type = casted_get_type ();
   
   /* Ensure vfs in modules loaded */
-  g_io_modules_ensure_loaded (GIO_MODULE_DIR);
+  _g_io_modules_ensure_loaded ();
 
   vfs_impls = g_type_children (G_TYPE_VFS, &n_vfs_impls);