Enable launchd.
[platform/upstream/dbus.git] / dbus / dbus-mainloop.c
index 6da5318..96ba599 100644 (file)
@@ -1,9 +1,9 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* dbus-mainloop.c  Main loop utility
  *
- * Copyright (C) 2003  Red Hat, Inc.
+ * Copyright (C) 2003, 2004  Red Hat, Inc.
  *
- * Licensed under the Academic Free License version 1.2
+ * Licensed under the Academic Free License version 2.1
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
+#include <config.h>
 #include "dbus-mainloop.h"
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
 #define MAINLOOP_SPEW 0
 
+#if MAINLOOP_SPEW
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+static const char*
+watch_flags_to_string (int flags)
+{
+  const char *watch_type;
+
+  if ((flags & DBUS_WATCH_READABLE) &&
+      (flags & DBUS_WATCH_WRITABLE))
+    watch_type = "readwrite";
+  else if (flags & DBUS_WATCH_READABLE)
+    watch_type = "read";
+  else if (flags & DBUS_WATCH_WRITABLE)
+    watch_type = "write";
+  else
+    watch_type = "not read or write";
+  return watch_type;
+}
+#endif /* DBUS_ENABLE_VERBOSE_MODE */
+#endif /* MAINLOOP_SPEW */
+
 struct DBusLoop
 {
   int refcount;
@@ -123,12 +145,14 @@ timeout_callback_new (DBusTimeout         *timeout,
   return cb;
 }
 
-static void
+static Callback * 
 callback_ref (Callback *cb)
 {
   _dbus_assert (cb->refcount > 0);
   
   cb->refcount += 1;
+
+  return cb;
 }
 
 static void
@@ -204,13 +228,15 @@ _dbus_loop_new (void)
   return loop;
 }
 
-void
+DBusLoop *
 _dbus_loop_ref (DBusLoop *loop)
 {
   _dbus_assert (loop != NULL);
   _dbus_assert (loop->refcount > 0);
 
   loop->refcount += 1;
+
+  return loop;
 }
 
 void
@@ -573,7 +599,7 @@ _dbus_loop_iterate (DBusLoop     *loop,
 
 #if MAINLOOP_SPEW
               _dbus_verbose ("  skipping watch on fd %d as it was out of memory last time\n",
-                             dbus_watch_get_fd (wcb->watch));
+                             dbus_watch_get_socket (wcb->watch));
 #endif
             }
           else if (dbus_watch_get_enabled (wcb->watch))
@@ -584,7 +610,7 @@ _dbus_loop_iterate (DBusLoop     *loop,
                   
               flags = dbus_watch_get_flags (wcb->watch);
                   
-              fds[n_fds].fd = dbus_watch_get_fd (wcb->watch);
+              fds[n_fds].fd = dbus_watch_get_socket (wcb->watch);
               fds[n_fds].revents = 0;
               fds[n_fds].events = 0;
               if (flags & DBUS_WATCH_READABLE)
@@ -593,7 +619,8 @@ _dbus_loop_iterate (DBusLoop     *loop,
                 fds[n_fds].events |= _DBUS_POLLOUT;
 
 #if MAINLOOP_SPEW
-              _dbus_verbose ("  polling watch on fd %d\n", fds[n_fds].fd);
+              _dbus_verbose ("  polling watch on fd %d  %s\n",
+                             fds[n_fds].fd, watch_flags_to_string (flags));
 #endif
 
               n_fds += 1;
@@ -601,8 +628,9 @@ _dbus_loop_iterate (DBusLoop     *loop,
           else
             {
 #if MAINLOOP_SPEW
-              _dbus_verbose ("  skipping disabled watch on fd %d\n",
-                             dbus_watch_get_fd (wcb->watch));
+              _dbus_verbose ("  skipping disabled watch on fd %d  %s\n",
+                             dbus_watch_get_socket (wcb->watch),
+                             watch_flags_to_string (dbus_watch_get_flags (wcb->watch)));
 #endif
             }
         }
@@ -878,4 +906,4 @@ _dbus_wait_for_memory (void)
   _dbus_sleep_milliseconds (_dbus_get_oom_wait ());
 }
 
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+#endif /* !DOXYGEN_SHOULD_SKIP_THIS */