$NetBSD: patch-ae,v 1.1 2009/11/26 12:30:12 obache Exp $

--- agent/scim-bridge-agent-accept-listener.cpp.orig	2009-04-19 03:42:18.000000000 +0000
+++ agent/scim-bridge-agent-accept-listener.cpp
@@ -30,6 +30,10 @@
 #include <sys/types.h>
 #include <sys/un.h>
 
+#ifndef SUN_LEN
+#define SUN_LEN(x) (sizeof(*(x)) - sizeof((x)->sun_path +  strlen ((x)->sun_path))
+#endif
+
 #include "scim-bridge-output.h"
 #include "scim-bridge-path.h"
 
@@ -111,7 +115,7 @@ retval_t ScimBridgeAgentAcceptListenerIm
     const int MAX_TRIAL = 5;
     for (int i = 0; i < MAX_TRIAL; ++i) {
         scim_bridge_pdebugln (8, "Pinging for the another agent process...");
-        if (connect (socket_fd, (struct sockaddr*)&socket_addr, sizeof (socket_addr.sun_family) + strlen (socket_addr.sun_path))) {
+        if (connect (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr))) {
             if (i == MAX_TRIAL - 1) {
                 scim_bridge_pdebugln (6, "It seems like there is no other agent for the old socket.");
                 break;
@@ -163,7 +167,7 @@ retval_t ScimBridgeAgentAcceptListenerIm
         return RETVAL_FAILED;
     }
     
-    if (bind (socket_fd, (struct sockaddr*)&socket_addr, strlen (socket_addr.sun_path) + sizeof (socket_addr.sun_family)) != 0) {
+    if (bind (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr)) != 0) {
         scim_bridge_perrorln ("Cannot bind the socket: %s", strerror (errno));
         close (socket_fd);
         socket_fd = -1;
