[openi18n-im:01158] iiimf Client Emacs (IIIMECF) improvement
Hiroshi Miura <[email protected]>
| Newsgroups | gmane.comp.internationalization.input-methods |
|---|---|
| Message-ID | <876522kus7.wl%[email protected]> |
Hi,
iiimecf 0.6, bandled with im-sdk, cannot support unix domain socket.
But now iiimf server uses unix domain socket by default.
http://www.openi18n.org/mantis/bug_view_page.php?bug_id=0000017
I'm trying to supprt unix domain socket using helper program on IIIMECF.
After trial, it can connect but not work properly with ATOK X2.
Emacs seems wait a reply from server and I can break with Ctrl-g key.
There are messages of *IIIMP debug* buffer with my patch.
The patch and helper source are attached.
With may patch, user can set
(setq iiimcf-server-control-hostlist '("unix"))
Does anyone help me?
Sending[iiimp-im-connect]:("miura@localhost")
Received:(iiimp-im-connect-reply [#<process IIIMP> #<buffer *IIIMP*> "unix" 9010 17] (1 [#<process IIIMP> #<buffer *IIIMP*> "unix" 9010 17]) nil ("ja"))
Sending[iiimp-im-setimvalues]:((1 [#<process IIIMP> #<buffer *IIIMP*> "unix" 9010 17]) ((client-descriptor ("IIIMCF-SC/0.6 (Adumi) IIIMECF/0.6 (Amida) Emacs/21.3.1" "linux-gnu" "i386" "Unknown"))))
Received:(iiimp-im-register-trigger-keys [#<process IIIMP> #<buffer *IIIMP*> "unix" 9010 97] (1 [#<process IIIMP> #<buffer *IIIMP*> "unix" 9010 97]) nil (((0 . 25) (0 . 25) (0 . 0) (0 . 0)) ((0 . 32) (0 . 32) (0 . 2) (0 . 0))) (((0 . 25) (0 . 25) (0 . 0) (0 . 0)) ((0 . 32) (0 . 32) (0 . 2) (0 . 0))))
Hiroshi Miura --- http://www.da-cha.org/ --- [email protected]
NTTDATA Corp. OpenSource Software Center. --- [email protected]
NTTDATA Intellilink Corp. OpenSource Engineering Dev. -- [email protected]
Key fingerprint = 9117 9407 5684 FBF1 4063 15B4 401D D077 04AB 8617
iiimp.c
(application/octet-stream, 2.3 KB)
/* iiimp.c * VERSION: 0.1 * AUTHOR: [email protected] * DATE: 2005.01.10 * * This is almostly come from icanna.c on yc-el package. * * -Original copyright notice. * icanna.c * VERSION: 0.9.0 * AUTHER: [email protected] * DATE: 2003.9.29 * LICENCE: GPL */ /* * communicate unix domain iiim server * stdin -> iiim server -> stdout */ #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include <sys/un.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #define BFSZ (4096) /* buffer size */ #define IIIM_PATH ("/var/run/iiim/.iiimp-unix/9010") /* unix domain socket path */ /* * connect unix domain iiimp server */ int connect_iiimp_server() { int iiimp; struct sockaddr_un sun; /* create unix domain socket */ if ((iiimp = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } /* connect iiimp server */ sun.sun_family = AF_UNIX; strcpy(sun.sun_path, IIIM_PATH); if (connect(iiimp, (struct sockaddr*)&sun, SUN_LEN(&sun)) < 0) { perror("connect"); exit(1); } return iiimp; } /* * data transport * stdin -> iiim * iiim -> stdout */ int transport(in, out) int in, out; { char* buf = NULL; /* data buffer */ int len = BFSZ; /* data length */ int count = -1; /* read count */ /* read input */ while (len == BFSZ) { count++; /* allocate data buffer */ if ((buf = (char*)realloc(buf, (count + 1) * BFSZ)) == NULL) { perror("realloc"); exit(1); } /* read input to data buffer */ if ((len = read(in, buf + count * BFSZ, BFSZ)) < 0) { perror("read"); exit(1); } } len += count * BFSZ; /* write output */ if (len > 0 && write(out, buf, len) < 0) { perror("write"); exit(1); } /* destroy data buffer */ free(buf); return len; } /* * communicate unix domain iiim server */ int main() { int iiimp; iiimp = connect_iiimp_server(); /* connect unix domain socket */ /* transport request & response, until stdin or socket is eof */ while (1) /* transport request from stdin to iiim server, * transport response from iiim server to stdout */ if (transport(0, iiimp) == 0 || transport(iiimp, 1) == 0) /* when stdin or iiim server is eof, break loop */ break; close(iiimp); /* close unix domain iiim server */ return 0; }
iiimp.diff
(application/octet-stream, 1.6 KB)
diff -u IIIMECF-0.6/lisp/iiimp.el iiimecf-0.6-6/lisp/iiimp.el
--- IIIMECF-0.6/lisp/iiimp.el 2002-07-15 20:18:13.000000000 +0900
+++ iiimecf-0.6-6/lisp/iiimp.el 2005-01-12 23:41:38.000000000 +0900
@@ -68,6 +68,8 @@
(defvar iiimp-text-warning-char ?!)
+(defvar iiimp-helper-path "iiimp")
+
(defconst iiimp-basic-opcode-spec-list
'((iiimp-im-no-protocol
0 (nil . nil)
@@ -360,8 +362,9 @@
;;; network I/O
(defsubst iiimp-check-channel-connection (com-id)
- (eq (process-status (iiimp-com-id-process com-id)) 'open))
-
+ (or (eq (process-status (iiimp-com-id-process com-id)) 'open)
+ (eq (process-status (iiimp-com-id-process com-id)) 'run)))
+
(defun iiimp-proc-to-com-id (proc)
(let ((oldbuf (current-buffer))
(nbuf (process-buffer proc)))
@@ -391,7 +394,10 @@
(set-buffer-multibyte nil))
(buffer-disable-undo buf)
(setq proc
- (open-network-stream iiimp-process-name buf host port))
+ (cond ((string= host "unix")
+ (let ((process-connection-type nil))
+ (start-process iiimp-process-name buf iiimp-helper-path)))
+ (t (open-network-stream iiimp-process-name buf host port))))
(process-kill-without-query proc)
(set-process-coding-system proc 'binary 'binary)
(set-process-sentinel
@@ -407,7 +413,8 @@
(defun iiimp-destroy-network-channel (com-id)
(let* ((proc (iiimp-com-id-process com-id))
(stat (process-status proc)))
- (while (not (or (eq stat 'closed)
+ (while (not (or (or (eq stat 'closed)
+ (eq stat 'exit))
(eq stat nil)))
(set-process-sentinel proc nil)
(delete-process proc)