[uim-commit] r349 - trunk/fep

yamamoto@freedesktop.org yamamoto@freedesktop.org
Sat Jan 22 01:32:54 PST 2005


Author: yamamoto
Date: 2005-01-22 01:32:51 -0800 (Sat, 22 Jan 2005)
New Revision: 349

Modified:
   trunk/fep/draw.c
   trunk/fep/uim-fep-tick.c
   trunk/fep/uim-fep.c
Log:
 * fep/uim-fep.c: fix bugs related UIM_FEP_GETMODE and UIM_FEP_SETMODE
 * fep/uim-fep-tick.c (version): replace fprint(stderr) with printf
 * fep/draw.c: fix a comment


Modified: trunk/fep/draw.c
===================================================================
--- trunk/fep/draw.c	2005-01-22 06:28:57 UTC (rev 348)
+++ trunk/fep/draw.c	2005-01-22 09:32:51 UTC (rev 349)
@@ -506,7 +506,7 @@
 
   if (force || mode != prev_mode) {
 
-    /* ¸½ºß¤Î¥â¡¼¥É¤òUIM_FEP_SETMODE¤Ë½ñ¤­¹þ¤à */
+    /* ¸½ºß¤Î¥â¡¼¥É¤òUIM_FEP_GETMODE¤Ë½ñ¤­¹þ¤à */
     if (s_path_getmode[0] != '\0') {
       FILE *fp = fopen(s_path_getmode, "wt");
       if (fp) {

Modified: trunk/fep/uim-fep-tick.c
===================================================================
--- trunk/fep/uim-fep-tick.c	2005-01-22 06:28:57 UTC (rev 348)
+++ trunk/fep/uim-fep-tick.c	2005-01-22 09:32:51 UTC (rev 349)
@@ -108,7 +108,7 @@
 
 static void version(void)
 {
-  fprintf(stderr, "uim-fep-tick %s\n", PACKAGE_VERSION);
+  printf("uim-fep-tick %s\n", PACKAGE_VERSION);
 }
 
 static void usage(void)

Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c	2005-01-22 06:28:57 UTC (rev 348)
+++ trunk/fep/uim-fep.c	2005-01-22 09:32:51 UTC (rev 349)
@@ -228,6 +228,11 @@
     return EXIT_FAILURE;
   }
 
+  if (getenv("UIM_FEP_PID")) {
+    puts("uim-fep is already running");
+    return EXIT_FAILURE;
+  }
+
   init_str();
 
   tcgetattr(STDIN_FILENO, &s_save_tios);
@@ -250,15 +255,21 @@
   env_buf = malloc(30);
   snprintf(env_buf, 30, "UIM_FEP_PID=%d", getpid());
   putenv(env_buf);
-  env_buf = malloc(strlen("UIM_FEP_GETMODE=") + strlen(s_path_getmode) + 1);
-  sprintf(env_buf, "UIM_FEP_GETMODE=%s", s_path_getmode);
-  putenv(env_buf);
 
+  if (fopen(s_path_getmode, "wt") != NULL) {
+    unlink(s_path_getmode);
+    env_buf = malloc(strlen("UIM_FEP_GETMODE=") + strlen(s_path_getmode) + 1);
+    sprintf(env_buf, "UIM_FEP_GETMODE=%s", s_path_getmode);
+    putenv(env_buf);
+  } else {
+    s_path_getmode[0] = '\0';
+  }
+
   if (mkfifo(s_path_setmode, 0600) != -1) {
+    unlink(s_path_setmode);
     env_buf = malloc(strlen("UIM_FEP_SETMODE=") + strlen(s_path_setmode) + 1);
     sprintf(env_buf, "UIM_FEP_SETMODE=%s", s_path_setmode);
     putenv(env_buf);
-    s_setmode_fd = open(s_path_setmode, O_RDONLY | O_NONBLOCK);
   } else {
     s_path_setmode[0] = '\0';
     s_setmode_fd = -1;
@@ -398,6 +409,14 @@
   init_draw(s_context, on_the_spot, s_status_type, s_master, s_path_getmode);
   init_escseq(use_civis, on_the_spot, s_status_type, &attr_uim);
   set_signal_handler();
+
+  if (s_path_setmode[0] != '\0' && mkfifo(s_path_setmode, 0600) != -1) {
+    s_setmode_fd = open(s_path_setmode, O_RDONLY | O_NONBLOCK);
+  } else {
+    s_path_setmode[0] = '\0';
+    s_setmode_fd = -1;
+  }
+
   main_loop();
   done(EXIT_SUCCESS);
   return EXIT_SUCCESS;



More information about the Uim-commit mailing list