summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2009-03-02 13:05:22 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2009-03-02 13:05:22 +0800
commite1c8775b084f3c5080e185a94d0e41f185526eba (patch)
tree2281d6ab830389387d797eac09e309e286595b55
parentcd4d9b6ebfa4a66ba6bd89c5b7d2b34eb25864af (diff)
downloadibus-e1c8775b084f3c5080e185a94d0e41f185526eba.tar.gz
ibus-e1c8775b084f3c5080e185a94d0e41f185526eba.tar.xz
ibus-e1c8775b084f3c5080e185a94d0e41f185526eba.zip
Fix some compile problems with Sun C compiler.
-rw-r--r--bus/Makefile.am1
-rw-r--r--bus/main.c48
-rw-r--r--client/x11/main.c10
-rw-r--r--configure.ac3
-rw-r--r--src/ibushotkey.c8
-rw-r--r--src/ibusmessage.c2
-rw-r--r--src/ibuspendingcall.c2
-rw-r--r--util/IMdkit/i18nX.c4
8 files changed, 63 insertions, 15 deletions
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 526ac21..1b57a07 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -22,6 +22,7 @@
libibus = $(top_builddir)/src/libibus.la
INCLUDES = \
+ -I$(top_srcdir) \
-I$(top_srcdir)/src \
$(NULL)
diff --git a/bus/main.c b/bus/main.c
index 7e53144..13b13cc 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -17,9 +17,11 @@
* 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);
diff --git a/client/x11/main.c b/client/x11/main.c
index 6437d50..53389a9 100644
--- a/client/x11/main.c
+++ b/client/x11/main.c
@@ -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;
diff --git a/configure.ac b/configure.ac
index c40d8b0..2b6f0d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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, [
diff --git a/src/ibushotkey.c b/src/ibushotkey.c
index 81e506c..0f1b314 100644
--- a/src/ibushotkey.c
+++ b/src/ibushotkey.c
@@ -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));
diff --git a/src/ibusmessage.c b/src/ibusmessage.c
index 0541778..829a304 100644
--- a/src/ibusmessage.c
+++ b/src/ibusmessage.c
@@ -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
diff --git a/src/ibuspendingcall.c b/src/ibuspendingcall.c
index 2812dbf..e4b1053 100644
--- a/src/ibuspendingcall.c
+++ b/src/ibuspendingcall.c
@@ -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
diff --git a/util/IMdkit/i18nX.c b/util/IMdkit/i18nX.c
index a55dc6d..0ae92d2 100644
--- a/util/IMdkit/i18nX.c
+++ b/util/IMdkit/i18nX.c
@@ -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;