[uim-commit] r1193 - trunk/fep

yamamoto at freedesktop.org yamamoto at freedesktop.org
Sat Aug 13 15:03:29 EST 2005


Author: yamamoto
Date: 2005-08-12 22:03:26 -0700 (Fri, 12 Aug 2005)
New Revision: 1193

Modified:
   trunk/fep/README.ja
   trunk/fep/uim-fep.c
Log:
 * fep/uim-fep.c (main) : same as r1174


Modified: trunk/fep/README.ja
===================================================================
--- trunk/fep/README.ja	2005-08-13 04:23:10 UTC (rev 1192)
+++ trunk/fep/README.ja	2005-08-13 05:03:26 UTC (rev 1193)
@@ -170,8 +170,8 @@
     backtick¤¬»È¤ï¤ì¤Þ¤¹¡£
 
     UIM_FEP_SETMODE, UIM_FEP_GETMODE¤ÎÃͤÏ
-    $TMP/uim-fep-setmode-$STY-$WINDOW
-    $TMP/uim-fep-getmode-$STY-$WINDOW
+    $TMP/uim-fep-setmode-$STY-$WINDOW-screen
+    $TMP/uim-fep-getmode-$STY-$WINDOW-screen
     ¤Ë¤Ê¤ê¤Þ¤¹¡£
     ($TMP¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï/tmp¤¬»È¤ï¤ì¤ë)
 

Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c	2005-08-13 04:23:10 UTC (rev 1192)
+++ trunk/fep/uim-fep.c	2005-08-13 05:03:26 UTC (rev 1193)
@@ -227,6 +227,7 @@
   const char *tmp_dir;
   const char *sty_str;
   const char *win_str;
+  struct stat stat_buf;
 
   int op;
 
@@ -378,19 +379,44 @@
     tmp_dir = "/tmp";
   }
 
-  if (gnu_screen && (sty_str = getenv("STY")) != NULL && (win_str = getenv("WINDOW")) != NULL) {
+  sty_str = getenv("STY");
+  win_str = getenv("WINDOW");
+  if (gnu_screen) {
+    if (!(sty_str != NULL && win_str != NULL)) {
+      puts("STY and WINDOW are not defined");
+      return EXIT_FAILURE;
+    }
     snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s", tmp_dir, sty_str, win_str);
     snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s", tmp_dir, sty_str, win_str);
+    if (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
+      char msg[100];
+      init_sendsocket(sock_path);
+      snprintf(msg, 100, "uim-fep is already running on window %s", win_str);
+      sendline(msg);
+      return EXIT_FAILURE;
+    }
+    snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+    snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s-screen", tmp_dir, sty_str, win_str);
   } else {
-    struct stat stat_buf;
-    int file_suffix = 1;
+    if (sty_str != NULL && win_str != NULL) {
+      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s-screen", tmp_dir, sty_str, win_str);
+      if (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
+        printf("uim-fep is already running on window %s as filter\n", win_str);
+        return EXIT_FAILURE;
+      }
+      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%s-%s", tmp_dir, sty_str, win_str);
+      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%s-%s", tmp_dir, sty_str, win_str);
+    } else {
+      int file_suffix = 1;
 
-    snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d", tmp_dir, getpid());
-    snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d", tmp_dir, getpid());
-    while (stat(s_path_getmode, &stat_buf) == 0 && stat(s_path_setmode, &stat_buf) == 0) {
-      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d-%d", tmp_dir, getpid(), file_suffix);
-      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d-%d", tmp_dir, getpid(), file_suffix);
-      file_suffix++;
+      snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d", tmp_dir, getpid());
+      snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d", tmp_dir, getpid());
+      while (stat(s_path_getmode, &stat_buf) == 0 || stat(s_path_setmode, &stat_buf) == 0) {
+        snprintf(s_path_getmode, sizeof(s_path_getmode), "%s/uim-fep-getmode-%d-%d", tmp_dir, getpid(), file_suffix);
+        snprintf(s_path_setmode, sizeof(s_path_setmode), "%s/uim-fep-setmode-%d-%d", tmp_dir, getpid(), file_suffix);
+        file_suffix++;
+      }
     }
   }
 



More information about the uim-commit mailing list