Fix some compile problems with Sun C compiler.
authorHuang Peng <shawn.p.huang@gmail.com>
Mon, 2 Mar 2009 05:05:22 +0000 (13:05 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Mon, 2 Mar 2009 05:05:22 +0000 (13:05 +0800)
bus/Makefile.am
bus/main.c
client/x11/main.c
configure.ac
src/ibushotkey.c
src/ibusmessage.c
src/ibuspendingcall.c
util/IMdkit/i18nX.c

index 526ac21e4eba31a3cfaea625b01d8d09611f9cb8..1b57a07e714eeb0ce505c0eafec1c854d7018e1a 100644 (file)
@@ -22,6 +22,7 @@
 libibus = $(top_builddir)/src/libibus.la
 
 INCLUDES = \
+       -I$(top_srcdir) \
        -I$(top_srcdir)/src \
        $(NULL)
 
index 7e531442e9ee794c3d63dac213e30efdb7c08667..13b13cc37346052242b919408438fed3447b2493 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-
+#include <config.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include <stdlib.h>
 #include <locale.h>
@@ -87,6 +89,48 @@ execute_cmdline (const gchar *cmdline)
     return TRUE;
 }
 
+#ifndef HAVE_DAEMON
+void closeall(int fd)
+{
+    int fdlimit = sysconf(_SC_OPEN_MAX);
+
+    while (fd < fdlimit)
+      close(fd++);
+}
+
+int daemon(int nochdir, int noclose)
+{
+    switch (fork())
+    {
+        case 0:  break;
+        case -1: return -1;
+        default: _exit(0);
+    }
+
+    if (setsid() < 0)
+      return -1;
+
+    switch (fork())
+    {
+        case 0:  break;
+        case -1: return -1;
+        default: _exit(0);
+    }
+
+    if (!nochdir)
+      chdir("/");
+
+    if (!noclose)
+    {
+        closeall(0);
+        open("/dev/null",O_RDWR);
+        dup(0); dup(0);
+    }
+
+    return 0;
+}
+#endif
+
 gint
 main (gint argc, gchar **argv)
 {
@@ -110,7 +154,7 @@ main (gint argc, gchar **argv)
 
     /* check uid */
     {
-        gchar *username = ibus_get_user_name ();
+        const gchar *username = ibus_get_user_name ();
         uid_t uid = getuid ();
         struct passwd *pwd = getpwuid (uid);
 
index 6437d50bb7878ba04f91c0b45449d8f9c7d08e65..53389a9d6fac15822fd43497e42fc5f0a67d13bf 100644 (file)
@@ -936,11 +936,11 @@ _xim_init_IMdkit ()
     };
 
     GdkWindowAttr window_attr = {
-        title : "ibus-xim",
-        event_mask : GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
-        wclass : GDK_INPUT_OUTPUT,
-        window_type : GDK_WINDOW_TOPLEVEL,
-        override_redirect : 1,
+        .title              = "ibus-xim",
+        .event_mask         = GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
+        .wclass             = GDK_INPUT_OUTPUT,
+        .window_type        = GDK_WINDOW_TOPLEVEL,
+        .override_redirect   = 1,
     };
 
     XIMStyles styles;
index c40d8b072aa28825f35cf15fefdedccf1ad44c40..2b6f0d8c6bfedf756a2df10a5fdaf6135422f00d 100644 (file)
@@ -61,6 +61,9 @@ AC_SUBST(LT_VERSION_INFO)
 # check inotify
 AC_CHECK_HEADERS([sys/inotify.h])
 
+# check funcs
+AC_CHECK_FUNCS(daemon)
+
 # check glib2
 AM_PATH_GLIB_2_0
 PKG_CHECK_MODULES(GLIB2, [
index 81e506c4c2393c1da1cb7859661698400fe6522c..0f1b3143409b907f26b54a2a5ed5ef4b0adecf96 100644 (file)
@@ -390,8 +390,8 @@ ibus_hotkey_profile_remove_hotkey (IBusHotkeyProfile *profile,
     priv = IBUS_HOTKEY_PROFILE_GET_PRIVATE (profile);
 
     IBusHotkey hotkey = {
-        keyval : keyval,
-        modifiers : modifiers
+        .keyval = keyval,
+        .modifiers = modifiers
     };
 
     IBusHotkey *p1;
@@ -465,8 +465,8 @@ ibus_hotkey_profile_filter_key_event (IBusHotkeyProfile *profile,
     priv = IBUS_HOTKEY_PROFILE_GET_PRIVATE (profile);
 
     IBusHotkey hotkey = {
-        keyval : keyval,
-        modifiers : modifiers & priv->mask,
+        .keyval = keyval,
+        .modifiers = modifiers & priv->mask,
     };
 
     GQuark event = (GQuark) GPOINTER_TO_UINT (g_tree_lookup (priv->hotkeys, &hotkey));
index 05417786db8a79209922fdb5a76987c4a03a9f2b..829a304762fc72d0f0edfc63627023af6c323cc8 100644 (file)
@@ -261,7 +261,7 @@ void
 ibus_message_set_no_reply (IBusMessage  *message,
                            gboolean      no_reply)
 {
-    return dbus_message_set_no_reply (message, no_reply);
+    dbus_message_set_no_reply (message, no_reply);
 }
 
 gboolean
index 2812dbfaf92f68ce90d87aa17a97914561ad2108..e4b105373079d8e600278376787264ab388ed911 100644 (file)
@@ -61,7 +61,7 @@ ibus_pending_call_steal_reply (IBusPendingCall *pending)
 void
 ibus_pending_call_block (IBusPendingCall *pending)
 {
-    return dbus_pending_call_block (pending);
+    dbus_pending_call_block (pending);
 }
 
 void
index a55dc6d8c0f70ab16d8007aeb6d20d414fe3ab53..0ae92d2fe65d5d291cf8e53bbf4eab948a05b97f 100644 (file)
@@ -144,7 +144,7 @@ static unsigned char *ReadXIMMessage (XIMS ims,
             get_length = LONG_MAX;
         get_length /= 4;
         if (get_length == 0) {
-            fprintf(stderr, "%s: invalid length 0\n", __FUNCTION__);
+            fprintf(stderr, "%s: invalid length 0\n", __func__);
             return NULL;
         }
         return_code = XGetWindowProperty (i18n_core->address.dpy,
@@ -178,7 +178,7 @@ static unsigned char *ReadXIMMessage (XIMS ims,
             break;
         default:
             fprintf(stderr, "%s: unknown property return format: %d\n",
-                        __FUNCTION__, actual_format_ret);
+                        __func__, actual_format_ret);
             XFree(prop);
             client->property_offset = 0;
             return NULL;